Skip to content

Instantly share code, notes, and snippets.

@jakepage91
Created July 12, 2023 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakepage91/808ba3a60bdd833e4d276805a1715d10 to your computer and use it in GitHub Desktop.
Save jakepage91/808ba3a60bdd833e4d276805a1715d10 to your computer and use it in GitHub Desktop.
Komiser + Grafana gist
[[aws]]
name="Production"
source="CREDENTIALS_FILE"
path="/usr/bin/credentials"
profile="default"
[[mongodbatlas]]
name="Staging"
organizationId="orgIdValue"
publicApiKey="publicApiKeyValue"
privateApiKey="privateApiKeyValue"
[[civo]]
name="Development"
token="civoToken"
[postgres]
uri="postgres://komiser:komiser@postgres:5432/komiser?sslmode=disable"
version: '3.1'
services:
komiser:
image: tailwarden/komiser:3.0.20
restart: always
platform: linux/amd64
command: "--config /usr/bin/config.toml"
links:
- postgres
volumes:
- $PWD/config.toml:/usr/bin/config.toml
- /path/to/local/.aws/credentials:/usr/bin/credentials
depends_on:
- postgres
ports:
- 3000:3000
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- 3001:3000
links:
- postgres
postgres:
image: postgres:13
restart: always
environment:
- POSTGRES_DB=komiser
- POSTGRES_USER=komiser
- POSTGRES_PASSWORD=komiser
ports:
- 5432:5432
{
"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": 1,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 0,
"y": 0
},
"id": 5,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.1",
"targets": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT COUNT(DISTINCT account) FROM resources;",
"refId": "A",
"sql": {
"columns": [
{
"name": "COUNT",
"parameters": [
{
"name": "account",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "resources"
}
],
"title": "Cloud Accounts",
"type": "stat"
},
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": []
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 8,
"y": 0
},
"id": 2,
"options": {
"displayLabels": [
"percent"
],
"legend": {
"displayMode": "list",
"placement": "right",
"showLegend": true,
"values": []
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.0.1",
"targets": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "builder",
"format": "table",
"rawSql": "SELECT COUNT(*), service FROM resources WHERE account = '[[Account]]' GROUP BY service LIMIT 50 ",
"refId": "A",
"sql": {
"columns": [
{
"name": "COUNT",
"parameters": [
{
"name": "*",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "service",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"name": "service",
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50,
"whereJsonTree": {
"children1": [
{
"id": "99a998ba-4567-489a-bcde-f189443ebd27",
"properties": {
"field": "account",
"operator": "equal",
"value": [
"[[Account]]"
],
"valueSrc": [
"value"
],
"valueType": [
"text"
]
},
"type": "rule"
}
],
"id": "baa9abab-89ab-4cde-b012-3189442b3fa7",
"type": "group"
},
"whereString": "account = '[[Account]]'"
},
"table": "resources"
}
],
"title": "Breakdown by service",
"type": "piechart"
},
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-GrYlRd"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 8,
"x": 0,
"y": 4
},
"id": 3,
"options": {
"displayMode": "basic",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"valueMode": "color"
},
"pluginVersion": "10.0.1",
"targets": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "code",
"format": "table",
"hide": false,
"rawQuery": true,
"rawSql": "SELECT COUNT(*) as \"Tagged Resources\" FROM resources WHERE jsonb_array_length(tags) != 0 LIMIT 50;",
"refId": "Tagged Resources",
"sql": {
"columns": [
{
"parameters": [
{
"name": "tags",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "resources"
},
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT COUNT(*) AS \"Untagged Resources\" FROM resources WHERE jsonb_array_length(tags) = 0 LIMIT 50;",
"refId": "Untagged Resources",
"sql": {
"columns": [
{
"parameters": [
{
"name": "tags",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "resources"
}
],
"title": "Tags Coverage",
"type": "bargauge"
},
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": []
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 8,
"y": 8
},
"id": 4,
"options": {
"displayLabels": [
"percent"
],
"legend": {
"displayMode": "list",
"placement": "right",
"showLegend": true,
"values": []
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.0.1",
"targets": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "builder",
"format": "table",
"rawSql": "SELECT COUNT(*), region FROM resources GROUP BY region LIMIT 50 ",
"refId": "A",
"sql": {
"columns": [
{
"name": "COUNT",
"parameters": [
{
"name": "*",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "region",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"name": "region",
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "resources"
}
],
"title": "Breakdown by region",
"type": "piechart"
},
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 8,
"x": 0,
"y": 9
},
"id": 1,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.0.1",
"targets": [
{
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"editorMode": "builder",
"format": "table",
"rawSql": "SELECT COUNT(*) FROM resources WHERE account = '[[Account]]' LIMIT 50 ",
"refId": "A",
"sql": {
"columns": [
{
"name": "COUNT",
"parameters": [
{
"name": "*",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50,
"whereJsonTree": {
"children1": [
{
"id": "bb8b8b98-89ab-4cde-b012-31894438dab7",
"properties": {
"field": "account",
"operator": "equal",
"value": [
"[[Account]]"
],
"valueSrc": [
"value"
],
"valueType": [
"text"
]
},
"type": "rule"
}
],
"id": "baa9abab-89ab-4cde-b012-3189442b3fa7",
"type": "group"
},
"whereString": "account = '[[Account]]'"
},
"table": "resources"
}
],
"title": "Number of resources",
"type": "stat"
}
],
"refresh": "",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "Staging",
"value": "Staging"
},
"datasource": {
"type": "postgres",
"uid": "daabdbfc-a20c-44d7-8080-aa03281ab135"
},
"definition": "SELECT DISTINCT account FROM resources;",
"hide": 0,
"includeAll": false,
"multi": false,
"name": "Account",
"options": [],
"query": "SELECT DISTINCT account FROM resources;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Infrastructure Insights",
"uid": "ab0dad44-837f-4c6c-acd5-108b21506d47",
"version": 1,
"weekStart": ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment