Grafana Demo
Running grafana alongside Prometheus
- In the previous post we have been running Prometheus as a container, but we have mapped tcp port 9090 to the host.
- Now, we'll run grafana, but we want to make sure it can access prometheus, so that we run it using the host network:
1docker run -d -p 3000:3000 --network host --name grafana grafana/grafana-oss
- Default credentials:
admin/admin
Adding Prometheus as a Data Source
- Access grafans in your browser:
http://localhost:3000/ - Choose Connections, then Data sources
- Add Prometheus:
http://localhost:9090
Create a simple dashboard showing CPU and memory usage
-
Choose Dashboards from the left panel
-
Click on Add Dashboard
-
Click on Add Visualization
-
Select the default Prometheus as a data source
-
Create a query:
- Switch Builder to Code on the right
- You can now paste a PromQL query:
1100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
-
Configure options on the right:
- Title: "CPU Usage"
- Visualization type: Time series (this is at the top)
- Unit: Misc->Percent (0-100) (close sections to see the Standard options at the bottom)
- Min: 0, Max: 100
-
To see your dashboard, you may have to refresh your crowser, and go to Dashboards again