|
| 1 | +--- |
| 2 | +title: Metrics with Grafana and Prometheus |
| 3 | +description: A simple tutorial to display Quickwit metrics with Grafana. |
| 4 | +icon_url: /img/tutorials/quickwit-logo.png |
| 5 | +tags: [grafana, prometheus, integration] |
| 6 | +sidebar_position: 2 |
| 7 | +--- |
| 8 | + |
| 9 | +In this tutorial, you will learn how to set up Grafana to display Quickwit metrics using Prometheus. Grafana will visualize the metrics collected from Quickwit, allowing you to monitor its performance effectively. |
| 10 | + |
| 11 | +## Step 1: Create a Docker Compose File |
| 12 | + |
| 13 | +First, create a `docker-compose.yml` file in your project directory. This file will configure and run Quickwit, Prometheus, and Grafana as Docker services. |
| 14 | + |
| 15 | +Here’s the complete Docker Compose configuration: |
| 16 | + |
| 17 | +```yaml |
| 18 | +services: |
| 19 | + quickwit: |
| 20 | + image: quickwit/quickwit |
| 21 | + environment: |
| 22 | + QW_ENABLE_OPENTELEMETRY_OTLP_EXPORTER: "true" |
| 23 | + OTEL_EXPORTER_OTLP_ENDPOINT: "http://localhost:7281" |
| 24 | + ports: |
| 25 | + - 7280:7280 |
| 26 | + command: ["run"] |
| 27 | + |
| 28 | + grafana: |
| 29 | + image: grafana/grafana-oss |
| 30 | + container_name: grafana |
| 31 | + ports: |
| 32 | + - "${MAP_HOST_GRAFANA:-127.0.0.1}:3000:3000" |
| 33 | + environment: |
| 34 | + GF_INSTALL_PLUGINS: https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.4.6/quickwit-quickwit-datasource-0.4.6.zip;quickwit-quickwit-datasource |
| 35 | + GF_AUTH_DISABLE_LOGIN_FORM: "true" |
| 36 | + GF_AUTH_ANONYMOUS_ENABLED: "true" |
| 37 | + GF_AUTH_ANONYMOUS_ORG_ROLE: Admin |
| 38 | + |
| 39 | + prometheus: |
| 40 | + image: prom/prometheus:latest |
| 41 | + container_name: prometheus |
| 42 | + volumes: |
| 43 | + - ./prometheus.yml:/etc/prometheus/prometheus.yml # Ensure prometheus.yml exists in the same directory |
| 44 | + ports: |
| 45 | + - 9090:9090 |
| 46 | +``` |
| 47 | +
|
| 48 | +### Explanation of Services |
| 49 | +
|
| 50 | +- **Quickwit**: Runs the Quickwit service on port `7280`. |
| 51 | +- **Grafana**: Queries and displays data from Prometheus. |
| 52 | +- **Prometheus**: Collects metrics from Quickwit using the `/metrics` endpoint. |
| 53 | + |
| 54 | +## Step 2: Configure Prometheus |
| 55 | + |
| 56 | +Prometheus needs a configuration file to define how it scrapes metrics from Quickwit. Create a file named `prometheus.yml` in the same directory as your Docker Compose file with the following content: |
| 57 | + |
| 58 | +```yaml |
| 59 | +global: |
| 60 | + scrape_interval: 1s |
| 61 | + scrape_timeout: 1s |
| 62 | +
|
| 63 | +scrape_configs: |
| 64 | + - job_name: quickwit |
| 65 | + metrics_path: /metrics |
| 66 | + static_configs: |
| 67 | + - targets: |
| 68 | + - quickwit:7280 |
| 69 | +``` |
| 70 | + |
| 71 | +## Step 3: Start the Services |
| 72 | + |
| 73 | +Run the following command in your terminal to start all services defined in the Docker Compose file: |
| 74 | + |
| 75 | +```bash |
| 76 | +docker compose up |
| 77 | +``` |
| 78 | + |
| 79 | +This will launch Quickwit, Prometheus, and Grafana services. |
| 80 | + |
| 81 | +## Step 4: Configure Grafana to Use Prometheus |
| 82 | + |
| 83 | +1. Open Grafana in your browser at `http://localhost:3000`. |
| 84 | +2. Navigate to **Configuration** > **Data Sources**. |
| 85 | +3. Click **Add Data Source**, select **Prometheus**, and set the URL to `http://prometheus:9090`. |
| 86 | +4. Click **Save & Test** to verify the connection. |
| 87 | + |
| 88 | +## Step 5: Create or Use Pre-Configured Dashboards |
| 89 | + |
| 90 | +Now that Grafana is set up with Prometheus as a data source, you can create custom dashboards or use Quickwit's pre-configured dashboards: |
| 91 | + |
| 92 | +1. Go to the **Dashboards** section in Grafana. |
| 93 | +2. Import or create a new dashboard to visualize metrics. |
| 94 | +3. Alternatively, use one of Quickwit’s [pre-configured dashboards](../../operating/monitoring). |
| 95 | + |
0 commit comments