> For the complete documentation index, see [llms.txt](https://docs.neevcloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neevcloud.com/neevcloud-guide/neevcloud-knowledgebase/set-up-grafana/install-grafana-and-prometheus-on-ubuntu-22.04.md).

# Install Grafana and Prometheus on Ubuntu 22.04

## **Prerequisite:**

Ubuntu 22.04

Prometheus:  2.31.2

Grafana: 11.0

**Step-by-step instructions to install Grafana and Prometheus**

### Step 1: Update and upgrade the system:

To update and upgrade the package lists from the repositories, run the following command:

```
sudo apt-get update -y
sudo apt-get upgrade -y
```

### Step 2: Install Grafana:

Add the Grafana repository to your system. Open a terminal and run the following commands:

```
sudo apt-get install -y software-properties-common
```

<figure><img src="/files/hAytKAAuQ1eWMLxUn3Tk" alt=""><figcaption></figcaption></figure>

Add the Grafana package signing key and Install Grafana

```
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
```

<figure><img src="/files/cx22MtnlJP3sXO7AuOMr" alt=""><figcaption></figcaption></figure>

```
curl https://packages.grafana.com/gpg.key | sudo apt-key add -
```

<figure><img src="/files/J11m12NNFD1A9mTSnJod" alt=""><figcaption></figcaption></figure>

After adding the keys, update the system and install Grafana

```
sudo apt-get update && sudo apt-get install -y grafana
```

<figure><img src="/files/5TVRtMM1B77RO9cOcY76" alt=""><figcaption></figcaption></figure>

Start the Grafana service and enable it to start automatically at system reboot using the following commands:

```
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
```

### Step 3: Install Prometheus:

Install Prometheus using the following command:

```
sudo apt-get install prometheus -y
```

<figure><img src="/files/4I0nVJsuSbcwZkSdKviT" alt=""><figcaption></figcaption></figure>

Start the Prometheus service and enable it to start automatically at system reboot using the following commands:

```
sudo systemctl start prometheus
sudo systemctl enable prometheus
```

### **Check the version of Grafana and Prometheus:**

**Checking the Grafana Version**

To check the version of Grafana, run the curl command using the server IP and Grafana port number.

curl <http://your\\_server\\_ip:3000/api/health>

<figure><img src="/files/lqeH1bCUGBDEkdKQfVF4" alt=""><figcaption></figcaption></figure>

**Check the version of Prometheus**

To check the version of Prometheus, run these commands.

```
prometheus --version
```

<figure><img src="/files/mHbkle8SvgmhEvxaSeqI" alt=""><figcaption></figcaption></figure>

### Access Grafana via browser:

Access Grafana through a web browser: Open a web browser and go to **<http://Your\\_Server\\_IP:3000>.** Log in with the **default username and password (admin/admin)**. Follow the on-screen instructions to set up Grafana. Once loaded, you should see the Grafana login page. The default credentials are:

* username: admin
* password: admin

<figure><img src="/files/kYxkfvVlgsTHGCdpNtbF" alt=""><figcaption></figcaption></figure>

You'll be prompted to create a new password. Input a secure password, confirm it, and click the "Submit" button.

<figure><img src="/files/KQubg6xrw1whBZ0JbJTG" alt=""><figcaption></figcaption></figure>

## Attaching Prometheus to Grafana following these steps&#x20;

* Add Prometheus as a data source
* Click on the Grafana icon in the top left corner to show the main menu
* Select Data Sources.

<figure><img src="/files/rzca5kyeo1vfvjQCBjoh" alt=""><figcaption></figcaption></figure>

* Click Add Data Source.
* Choose Prometheus as the type.

<figure><img src="/files/FcWce3NydK8xt16zXsds" alt=""><figcaption></figcaption></figure>

Set the URL to <http://localhost:9090> (or the appropriate URL if Prometheus is on a different server).

{% hint style="info" %}
You need to replace the localhost with the IP address of your server.
{% endhint %}

Now click on the Save & Test.

<figure><img src="/files/gKodjahIHopbniqGXMAu" alt=""><figcaption></figcaption></figure>

Now create a dashboard.

<figure><img src="/files/VaO4Xn4V3sxPNy47wMyS" alt=""><figcaption></figcaption></figure>

Click on the Import Dashboard.

<figure><img src="/files/hHBAZCwcAwo2RuCRG26g" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/FGjMRtkcPakPCNSXB1KE" alt=""><figcaption></figcaption></figure>

Import the dashboard and save the dashboard back to the dashboard section click on the created dashboard and add visualization.

<figure><img src="/files/Mh3gt2POewnz4Di9Oe62" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eFdJjaoqroO7FApw8U2M" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/XjOqjekyYMDg5xsSuCqr" alt=""><figcaption></figcaption></figure>

After selecting Prometheus now configure the dashboard.

Select the matrix, define the labels, select the value, and run the query.

<figure><img src="/files/TJzZKjfVxEDsfvDOI0AC" alt=""><figcaption></figcaption></figure>

Upon running the queries, the status is displayed, and if you wish to modify the GRAF, simply click on the right side of the time series.

<figure><img src="/files/3mYvQzwgHjzxewX28Qgs" alt=""><figcaption></figcaption></figure>

**Key Features of Prometheus:**

* **Multi-dimensional Data Model:** Uses key-value pairs for labels to identify metrics uniquely.
* **Powerful Query Language (PromQL):** Allows flexible and high-dimensional data querying.
* **Pull-based Collection:** Scrapes metrics from HTTP endpoints at the targets' intervals.
* **Alerting:** Integrated alert manager that handles alerts based on PromQL expressions.
* **Compatibility:** Works well with containerized environments like Kubernetes.\\


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.neevcloud.com/neevcloud-guide/neevcloud-knowledgebase/set-up-grafana/install-grafana-and-prometheus-on-ubuntu-22.04.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
