Skip to content
Snippets Groups Projects
Commit 6336b56a authored by Alžbeta Hajná's avatar Alžbeta Hajná
Browse files

feat: grafana view from prometheus

parent 6d8e189b
No related branches found
No related tags found
2 merge requests!54Merge develop into main,!42Resolve "Actuator"
......@@ -164,10 +164,29 @@ docker-compose down
## Collecting Metrics
Create network for being able to communicate between two separate
docker images
```bash
docker network create grafana-prometheus
```
To collect the metrics in an automated way we use Prometheus.
First, make sure that every service you want to observe is running on predefined port.
Then run Prometheus in docker with respect to location of `prometheus.yml` file:
```bash
docker run --rm --name prometheus -p 9090:9090 -v ${PWD}/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:v2.43.0 --config.file=/etc/prometheus/prometheus.yml
docker run --rm --name prometheus --network grafana-prometheus --network-alias prometheus -p 9090:9090 -v ${PWD}/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:v2.43.0 --config.file=/etc/prometheus/prometheus.yml
```
## Grafana
Run Grafana in separate container:
```bash
docker run --rm --name grafana --network grafana-prometheus -p 3000:3000 grafana/grafana:9.1.7
```
1. Log into Grafana with default user and password is `admin`.
2. Add data source in Configuration -> Data sources (http://prometheus:9090)
3. Import Dashboard as JSON file (two options provided)
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "BhexAJs4z"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"__systemRef": "hideSeriesFrom",
"matcher": {
"id": "byNames",
"options": {
"mode": "exclude",
"names": [
"{__name__=\"disk_free_bytes\", instance=\"host.docker.internal:8080\", job=\"formula-core\", path=\"/.\"}"
],
"prefix": "All except:",
"readOnly": true
}
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"legend": false,
"tooltip": false,
"viz": true
}
}
]
}
]
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "p5SIZnEVk"
},
"editorMode": "builder",
"expr": "disk_free_bytes",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Free Bytes on Disk",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "BhexAJs4z"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 3,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "p5SIZnEVk"
},
"editorMode": "code",
"expr": "go_memstats_alloc_bytes",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Allocated Bytes",
"type": "timeseries"
},
{
"datasource": {},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 9
},
"id": 8,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "9.1.7",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "p5SIZnEVk"
},
"editorMode": "code",
"expr": "http_server_requests_seconds_count",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "HTTP Server Requests counter",
"type": "gauge"
}
],
"refresh": "5s",
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Formula Team Management",
"uid": "YDzAhnEVz",
"version": 3,
"weekStart": ""
}
\ No newline at end of file
This diff is collapsed.
......@@ -6,7 +6,7 @@ global:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['127.0.0.1:9090']
- targets: ['prometheus:9090']
- job_name: 'formula-core'
metrics_path: /actuator/prometheus
static_configs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment