Skip to content

Commit

Permalink
Make it easier to develop by having different datasources and dashboards
Browse files Browse the repository at this point in the history
Let's have a prometheus datasource and csv one.
For the CSV we will also add CSV file inside the container
  • Loading branch information
ekacnet committed May 7, 2024
1 parent 3734fc1 commit 1ffe3c6
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ARG pods_csv=/dev/null
ARG grafana_version=latest
ARG grafana_image=grafana-enterprise

Expand All @@ -13,4 +14,10 @@ ENV GF_DEFAULT_APP_MODE "development"

# Inject livereload script into grafana index.html
USER root
RUN grafana-cli plugins install marcusolsson-csv-datasource

# [plugin.marcusolsson-csv-datasource]
# allow_local_mode = true
RUN echo -ne "[plugin.marcusolsson-csv-datasource]\n allow_local_mode = true\n" >> /etc/grafana/grafana.ini
COPY ${pods_csv} /tmp/pods.csv
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ services:
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
grafana_version: ${GRAFANA_VERSION:-10.3.3}
networks:
- grafana
ports:
- 4000:3000/tcp
external_links:
- prometheus-app:prom

volumes:
- ./dist:/var/lib/grafana/plugins/ekacnet-cubismgrafana-panel
- ./provisioning:/etc/grafana/provisioning

networks:
grafana:
name: grafanacubism-panel_default
attachable: true
78 changes: 78 additions & 0 deletions provisioning/dashboards/dashboard2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 2,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "a0ce46a5-c7f8-4cec-997c-6314adf138a1"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"automaticExtents": true,
"extentMax": 10,
"extentMin": -10,
"seriesCountSize": "sm",
"showSeriesCount": false,
"text": ""
},
"targets": [
{
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "a0ce46a5-c7f8-4cec-997c-6314adf138a1"
},
"max": 10,
"min": -5,
"refId": "A",
"scenarioId": "random_walk",
"seriesCount": 10
}
],
"title": "Demo single",
"type": "ekacnet-cubismgrafana-panel"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Single panel dashboard",
"uid": "f930d956-0144-49fb-87dd-9c3d4a558e03",
"version": 2,
"weekStart": ""
}
112 changes: 112 additions & 0 deletions provisioning/dashboards/dashboard3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 3,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "marcusolsson-csv-datasource",
"uid": "a0ce46a5-c7f8-4cec-997c-6314adf138a2"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"automaticExtents": true,
"extentMax": 10,
"extentMin": -10,
"text": ""
},
"pluginVersion": "10.3.3",
"targets": [
{
"datasource": {
"type": "marcusolsson-csv-datasource",
"uid": "a0ce46a5-c7f8-4cec-997c-6314adf138a2"
},
"decimalSeparator": ".",
"delimiter": ",",
"header": true,
"ignoreUnknown": true,
"refId": "A",
"schema": [
{
"name": "aggregator-668c9957c7-btfgg",
"type": "number"
},
{
"name": "Time",
"type": "time"
}
],
"skipRows": 0,
"timezone": "America/Los_Angeles"
},
{
"datasource": {
"type": "marcusolsson-csv-datasource",
"uid": "a0ce46a5-c7f8-4cec-997c-6314adf138a2"
},
"decimalSeparator": ".",
"delimiter": ",",
"header": true,
"hide": false,
"ignoreUnknown": true,
"refId": "B",
"schema": [
{
"name": "Time",
"type": "time"
},
{
"name": "aggregator-7469f76bf4-ddmjm",
"type": "number"
}
],
"skipRows": 0,
"timezone": "America/Los_Angeles"
}
],
"title": "Aggregator CPU",
"type": "ekacnet-cubismgrafana-panel"
}
],
"refresh": false,
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "2024-04-17T03:28:45.000Z",
"to": "2024-04-17T05:49:15.000Z"
},
"timepicker": {},
"timezone": "",
"title": "K8s PODs",
"uid": "fdc65402-092c-4a87-9dd8-6112d7909fb9",
"version": 4,
"weekStart": ""
77 changes: 77 additions & 0 deletions provisioning/dashboards/dashboard4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 3,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "aaad26df-aaa4-4734-9904-74004d9a2d78"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"automaticExtents": false,
"extentMax": 50,
"extentMin": -10,
"text": ""
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "aaad26df-aaa4-4734-9904-74004d9a2d78"
},
"editorMode": "code",
"expr": "process_cpu_seconds_total",
"instant": false,
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
],
"title": "CPU containers",
"type": "ekacnet-cubismgrafana-panel"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "2024-04-17T05:23:05.839Z",
"to": "2024-04-19T05:23:05.839Z"
},
"timepicker": {},
"timezone": "",
"title": "CPU",
"uid": "ebcbe55f-f9ab-4f92-ab37-0311a0db5043",
"version": 3,
"weekStart": ""
}
12 changes: 12 additions & 0 deletions provisioning/datasources/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ datasources:
- name: grafana-testdata-datasource
type: testdata
uid: a0ce46a5-c7f8-4cec-997c-6314adf138a1
- name: csv-testdata-datasource
type: marcusolsson-csv-datasource
uid: a0ce46a5-c7f8-4cec-997c-6314adf138a2
url: /tmp/pods.csv
jsonData:
storage: local
- name: prometheus
type: prometheus
uid: aaad26df-aaa4-4734-9904-74004d9a2d78
url: http://172.23.0.3:9090
jsonData:
httpMethod: POST

0 comments on commit 1ffe3c6

Please sign in to comment.