master
Kar k1 2025-09-18 20:27:30 +05:30
parent 0b6b4db969
commit 1942a34b6d
3 changed files with 263 additions and 0 deletions

38
check_datasource.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Check if Grafana container is running
if ! docker-compose ps | grep -q grafana; then
echo "Grafana container is not running. Starting it now..."
docker-compose up -d grafana
sleep 10
fi
# Check if InfluxDB container is running
if ! docker-compose ps | grep -q influxdb; then
echo "InfluxDB container is not running. Starting it now..."
docker-compose up -d influxdb
sleep 10
fi
# Check if Telegraf container is running
if ! docker-compose ps | grep -q telegraf; then
echo "Telegraf container is not running. Starting it now..."
docker-compose up -d telegraf
sleep 5
fi
# Check if data is being written to InfluxDB
echo "Checking if data is being written to InfluxDB..."
docker-compose exec influxdb influx query 'from(bucket: "telegraf-bucket") |> range(start: -5m) |> filter(fn: (r) => r._measurement == "cpu") |> limit(n: 1)'
# Check Grafana data source configuration
echo -e "\nChecking Grafana data source configuration..."
docker-compose exec grafana grafana-cli admin data-sources list
# Check if the dashboard is loaded
echo -e "\nChecking if the dashboard is loaded..."
docker-compose exec grafana ls -la /etc/grafana/provisioning/dashboards/telegraf/
# Check Grafana logs for errors
echo -e "\nChecking Grafana logs for errors..."
docker-compose logs --tail=50 grafana | grep -i error || echo "No errors found in the last 50 lines of logs."

View File

@ -0,0 +1,221 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": "InfluxDB",
"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
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [
"mean",
"lastNotNull",
"max",
"min"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "influxdb",
"uid": "${DS_INFLUXDB}"
},
"query": "from(bucket: \"telegraf-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"cpu\" and r._field == \"usage_user\" and r.cpu == \"cpu-total\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
"refId": "A"
}
],
"title": "CPU Usage",
"type": "timeseries"
},
{
"datasource": "InfluxDB",
"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
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 4,
"options": {
"legend": {
"calcs": [
"mean",
"lastNotNull",
"max",
"min"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "influxdb",
"uid": "${DS_INFLUXDB}"
},
"query": "from(bucket: \"telegraf-bucket\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"mem\" and r._field == \"used_percent\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
"refId": "A"
}
],
"title": "Memory Usage",
"type": "timeseries"
}
],
"refresh": "5s",
"schemaVersion": 36,
"style": "dark",
"tags": ["telegraf", "system"],
"templating": {
"list": []
},
"time": {
"from": "now-15m",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Telegraf System Metrics",
"version": 1
}

View File

@ -57,6 +57,10 @@
"links": [],
"panels": [
{
"datasource": {
"type": "influxdb",
"uid": "${DS_INFLUXDB}"
},
"collapsed": false,
"gridPos": {
"h": 1,