-
Notifications
You must be signed in to change notification settings - Fork 1
Observabilidade
Vinicius Aguiar edited this page Dec 12, 2023
·
6 revisions
Adicionar loki como data source
- Selecione data source em configurações
- Adicione o data source loki com a url do service
Adicionar dashboard de backend
- Crie um dashboard vazio
- Acesse json model nas configurações
- Copie e cole o modelo abaixo com as modificações necessárias
{
"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": 29,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"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": []
},
"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": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "code",
"expr": "sum(count_over_time({app=\"$environment\"} [$__interval]))",
"queryType": "range",
"refId": "A"
}
],
"title": "Requisições",
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"gridPos": {
"h": 17,
"w": 12,
"x": 12,
"y": 0
},
"id": 8,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "code",
"expr": "{app=\"$environment\"} != `huey` != `elasticsearch` | json | __error__=``",
"queryType": "range",
"refId": "A"
}
],
"title": "Logs",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 9
},
"id": 4,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "code",
"expr": "{app=\"api-prod\"} |= \"huey\"",
"queryType": "range",
"refId": "A"
}
],
"title": "Tarefas (Huey)",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"gridPos": {
"h": 5,
"w": 24,
"x": 0,
"y": 17
},
"id": 6,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "code",
"expr": "{app=\"$environment\"} |= \"elasticsearch\"",
"queryType": "range",
"refId": "A"
}
],
"title": "Busca (Elasticsearch)",
"type": "logs"
}
],
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": true,
"text": "prd",
"value": "api-prod"
},
"hide": 0,
"includeAll": false,
"multi": false,
"name": "environment",
"options": [
{
"selected": true,
"text": "prd",
"value": "api-prod"
},
{
"selected": false,
"text": "stg",
"value": "api-staging"
},
{
"selected": false,
"text": "dev",
"value": "api-development"
}
],
"query": "prd : api-prod,stg : api-staging,dev : api-development",
"queryValue": "",
"skipUrlSync": false,
"type": "custom"
}
]
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Backend",
"uid": "Af1tq9SSk",
"version": 3,
"weekStart": ""
}
Adicionar dashboard do metabase
- Crie um dashboard vazio
- Acesse json model nas configurações
- Copie e cole o modelo abaixo com as modificações necessárias
{
"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": 30,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"gridPos": {
"h": 23,
"w": 12,
"x": 0,
"y": 0
},
"id": 4,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "code",
"expr": "{app=\"metabase\"} != `/api/health`",
"queryType": "range",
"refId": "A"
}
],
"title": "Logs",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"gridPos": {
"h": 23,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "ZG5SePISk"
},
"editorMode": "builder",
"expr": "{app=\"metabase\"} |= `/api/health`",
"queryType": "range",
"refId": "A"
}
],
"title": "Health Check",
"type": "logs"
}
],
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-3h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Metabase",
"uid": "tnBIzCISz",
"version": 4,
"weekStart": ""
}
Adicionar dashboard de metadados
- Crie um dashboard vazio
- Acesse json model nas configurações
- Copie e cole o modelo abaixo com as modificações necessárias
{
"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": 27,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "_tn2YivSk"
},
"gridPos": {
"h": 23,
"w": 12,
"x": 0,
"y": 0
},
"id": 4,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "_tn2YivSk"
},
"editorMode": "code",
"expr": "{app=\"api-prod\"} | json | record_extra_module = `api.v1` | label_format level=\"{{.record_level_name}}\" | line_format `{{.record_message}}` | record_level_name != `INFO`",
"queryType": "range",
"refId": "A"
}
],
"title": "Panel Title",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "_tn2YivSk"
},
"gridPos": {
"h": 23,
"w": 12,
"x": 12,
"y": 0
},
"id": 2,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "_tn2YivSk"
},
"editorMode": "code",
"expr": "{app=\"api-prod\"} | json | record_extra_module = `api.v1` | label_format level=\"{{.record_level_name}}\" | line_format `{{.record_message}}` | record_level_name = `INFO`",
"queryType": "range",
"refId": "A"
}
],
"title": "Logs da atualização de metadados",
"type": "logs"
}
],
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Metadados de Tabelas",
"uid": "_Lq-p0DIk",
"version": 2,
"weekStart": ""
}