Compare commits
5 Commits
2a6e9ba195
...
b86e377b8a
Author | SHA1 | Date | |
---|---|---|---|
|
b86e377b8a | ||
|
118a09bcf2 | ||
|
57b5846d51 | ||
|
31898a8a96 | ||
|
c4619f14da |
32
5-1-loki-dashboards-intro/docker-compose.yml
Normal file
32
5-1-loki-dashboards-intro/docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: "grafana/grafana:8.4.2"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
environment:
|
||||
- GF_PLUGINS_PLUGIN_ADMIN_ENABLED=true
|
||||
|
||||
loki:
|
||||
image: "grafana/loki:2.4.2"
|
||||
ports:
|
||||
- "3100:3100"
|
||||
|
||||
promtail:
|
||||
image: "grafana/promtail:2.4.2"
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
- ./promtail.yml:/etc/promtail/config.yaml
|
||||
command: -config.file=/etc/promtail/config.yaml
|
||||
|
||||
flog:
|
||||
image: "mingrammer/flog:0.4.3"
|
||||
command: -f json -t log -o /tmp/log/json.log -d 200ms -w -l
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
|
||||
volumes:
|
||||
logs_dir:
|
11
5-1-loki-dashboards-intro/promtail.yml
Normal file
11
5-1-loki-dashboards-intro/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
||||
clients:
|
||||
- url: http://loki:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: flogs
|
||||
__path__: /tmp/log/*.log
|
@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: http://loki:3100
|
||||
isDefault: true
|
||||
editable: true
|
32
5-2-loki-dashboards-flog/docker-compose.yml
Normal file
32
5-2-loki-dashboards-flog/docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: "grafana/grafana:8.4.2"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
environment:
|
||||
- GF_PLUGINS_PLUGIN_ADMIN_ENABLED=true
|
||||
|
||||
loki:
|
||||
image: "grafana/loki:2.4.2"
|
||||
ports:
|
||||
- "3100:3100"
|
||||
|
||||
promtail:
|
||||
image: "grafana/promtail:2.4.2"
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
- ./promtail.yml:/etc/promtail/config.yaml
|
||||
command: -config.file=/etc/promtail/config.yaml
|
||||
|
||||
flog:
|
||||
image: "mingrammer/flog:0.4.3"
|
||||
command: -f json -t log -o /tmp/log/json.log -d 200ms -w -l
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
|
||||
volumes:
|
||||
logs_dir:
|
11
5-2-loki-dashboards-flog/promtail.yml
Normal file
11
5-2-loki-dashboards-flog/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
||||
clients:
|
||||
- url: http://loki:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: flogs
|
||||
__path__: /tmp/log/*.log
|
@ -0,0 +1,9 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: 'Loki dashboards'
|
||||
type: file
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /etc/grafana/provisioning/dashboards/loki
|
||||
foldersFromFilesStructure: false
|
840
5-2-loki-dashboards-flog/provisioning/dashboards/loki/flog.json
Normal file
840
5-2-loki-dashboards-flog/provisioning/dashboards/loki/flog.json
Normal file
@ -0,0 +1,840 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"target": {
|
||||
"limit": 100,
|
||||
"matchAny": false,
|
||||
"tags": [],
|
||||
"type": "dashboard"
|
||||
},
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"enable": true,
|
||||
"expr": "{job=\"flogs\"} | json | bytes > 29900",
|
||||
"hide": false,
|
||||
"iconColor": "red",
|
||||
"name": "Show Large Requests",
|
||||
"target": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"id": 1,
|
||||
"iteration": 1648254271582,
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"panels": [
|
||||
{
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"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": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "{job=\"flogs\"}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Logs",
|
||||
"transparent": true,
|
||||
"type": "logs"
|
||||
},
|
||||
{
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"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
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "{job=\"flogs\"} | json | line_format \"{{ .method }} {{ .request }} 👉 {{ .status }} by {{ .user_identifier }} ({{div .bytes 1000}} kb)\" ",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Simplified logs",
|
||||
"transparent": true,
|
||||
"type": "logs"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"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": "decbytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 6
|
||||
},
|
||||
"id": 6,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "max_over_time({job=\"flogs\"} | json | unwrap bytes[5m]) by (status)",
|
||||
"legendFormat": "{{status}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Max size per HTTP status",
|
||||
"transparent": true,
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "decbytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 6
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "max_over_time({job=\"flogs\"} | json | unwrap bytes[5m]) by (method)",
|
||||
"legendFormat": "{{method}}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Max size per HTTP method",
|
||||
"transparent": true,
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
}
|
||||
},
|
||||
"mappings": []
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 7,
|
||||
"x": 0,
|
||||
"y": 12
|
||||
},
|
||||
"id": 5,
|
||||
"options": {
|
||||
"displayLabels": [],
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"values": [
|
||||
"value",
|
||||
"percent"
|
||||
]
|
||||
},
|
||||
"pieType": "pie",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "sum by (method) (count_over_time({job=\"flogs\"} | json [5m]))",
|
||||
"legendFormat": "{{method}}",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Distribution by method",
|
||||
"transparent": true,
|
||||
"type": "piechart"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
}
|
||||
},
|
||||
"mappings": []
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 7,
|
||||
"x": 8,
|
||||
"y": 12
|
||||
},
|
||||
"id": 7,
|
||||
"options": {
|
||||
"displayLabels": [],
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"values": [
|
||||
"value",
|
||||
"percent"
|
||||
]
|
||||
},
|
||||
"pieType": "pie",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "sum by (status) (count_over_time({job=\"flogs\"} | json [5m]))",
|
||||
"legendFormat": "{{status}}",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Distribution by status",
|
||||
"transparent": true,
|
||||
"type": "piechart"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
}
|
||||
},
|
||||
"mappings": []
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 7,
|
||||
"x": 15,
|
||||
"y": 12
|
||||
},
|
||||
"id": 13,
|
||||
"options": {
|
||||
"displayLabels": [],
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"values": [
|
||||
"value",
|
||||
"percent"
|
||||
]
|
||||
},
|
||||
"pieType": "pie",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "sum by (protocol) (count_over_time({job=\"flogs\"} | json [5m]))",
|
||||
"legendFormat": "{{protocol}}",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Distribution by protocol",
|
||||
"transparent": true,
|
||||
"type": "piechart"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-BlYlRd"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 0,
|
||||
"y": 18
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"colorMode": "background",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "sum(count_over_time({job=\"flogs\"} | json | user_identifier != \"-\" [5m])) / sum(count_over_time({job=\"flogs\"} [5m]))",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Identified requests (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-BlPu"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "percent"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 4,
|
||||
"y": 18
|
||||
},
|
||||
"id": 9,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "sum(count_over_time({job=\"flogs\"} | json | bytes > 10000[5m])) / sum(count_over_time({job=\"flogs\"} | json [5m])) * 100",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "> 10kb (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-BlPu"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 8,
|
||||
"y": 18
|
||||
},
|
||||
"id": 10,
|
||||
"options": {
|
||||
"colorMode": "background",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "count_over_time({job=\"flogs\"}[5m])",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Total lines (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-BlPu"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "/s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 12,
|
||||
"y": 18
|
||||
},
|
||||
"id": 18,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "rate({job=\"flogs\"}[5m])",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Lines/sec (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-YlBl"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "decbytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 16,
|
||||
"y": 18
|
||||
},
|
||||
"id": 11,
|
||||
"options": {
|
||||
"colorMode": "background",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "max(max_over_time({job=\"flogs\"} | json | unwrap bytes[5m]))",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Largest request body (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
},
|
||||
{
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "continuous-BlPu"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "binBps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 4,
|
||||
"x": 20,
|
||||
"y": 18
|
||||
},
|
||||
"id": 19,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"textMode": "auto"
|
||||
},
|
||||
"pluginVersion": "8.4.2",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "P8E80F9AEF21F6940"
|
||||
},
|
||||
"expr": "bytes_rate({job=\"flogs\"}[5m])",
|
||||
"queryType": "range",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Bytes/sec (5m)",
|
||||
"transparent": true,
|
||||
"type": "stat"
|
||||
}
|
||||
],
|
||||
"refresh": "",
|
||||
"schemaVersion": 35,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"current": {
|
||||
"selected": false,
|
||||
"text": "flogs",
|
||||
"value": "flogs"
|
||||
},
|
||||
"definition": "label_values(job)",
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"multi": false,
|
||||
"name": "job",
|
||||
"options": [],
|
||||
"query": "label_values(job)",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"skipUrlSync": false,
|
||||
"sort": 0,
|
||||
"type": "query"
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-5m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Loki flog example",
|
||||
"uid": "_JSEbzL7z",
|
||||
"version": 14,
|
||||
"weekStart": ""
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: http://loki:3100
|
||||
isDefault: true
|
||||
editable: true
|
32
5-3-loki-dashboards-nginx/docker-compose.yml
Normal file
32
5-3-loki-dashboards-nginx/docker-compose.yml
Normal file
@ -0,0 +1,32 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: "grafana/grafana:8.4.2"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
environment:
|
||||
- GF_PLUGINS_PLUGIN_ADMIN_ENABLED=true
|
||||
|
||||
loki:
|
||||
image: "grafana/loki:2.4.2"
|
||||
ports:
|
||||
- "3100:3100"
|
||||
|
||||
promtail:
|
||||
image: "grafana/promtail:2.4.2"
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
- ./promtail.yml:/etc/promtail/config.yaml
|
||||
command: -config.file=/etc/promtail/config.yaml
|
||||
|
||||
flog:
|
||||
image: "mingrammer/flog:0.4.3"
|
||||
command: -f json -t log -o /tmp/log/json.log -d 200ms -w -l
|
||||
volumes:
|
||||
- logs_dir:/tmp/log
|
||||
|
||||
volumes:
|
||||
logs_dir:
|
11
5-3-loki-dashboards-nginx/promtail.yml
Normal file
11
5-3-loki-dashboards-nginx/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
||||
clients:
|
||||
- url: http://loki:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: flogs
|
||||
__path__: /tmp/log/*.log
|
@ -0,0 +1,9 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: 'Loki dashboards'
|
||||
type: file
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /etc/grafana/provisioning/dashboards/loki
|
||||
foldersFromFilesStructure: false
|
1926
5-3-loki-dashboards-nginx/provisioning/dashboards/loki/nginx.json
Normal file
1926
5-3-loki-dashboards-nginx/provisioning/dashboards/loki/nginx.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: http://loki:3100
|
||||
isDefault: true
|
||||
editable: true
|
21
6-1-loki-alerts/docker-compose.yml
Normal file
21
6-1-loki-alerts/docker-compose.yml
Normal file
@ -0,0 +1,21 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: "grafana/grafana:8.4.2"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
|
||||
loki:
|
||||
image: "grafana/loki:2.4.2"
|
||||
command: --config.file=/mnt/config/loki.yml
|
||||
ports:
|
||||
- "3100:3100"
|
||||
volumes:
|
||||
- ./loki.yml:/mnt/config/loki.yml
|
||||
- ./rules.yml:/etc/loki/rules/fake/rules.yml
|
||||
|
||||
volumes:
|
||||
logs_dir:
|
38
6-1-loki-alerts/loki.yml
Normal file
38
6-1-loki-alerts/loki.yml
Normal file
@ -0,0 +1,38 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
http_listen_address: 0.0.0.0
|
||||
|
||||
ruler:
|
||||
evaluation_interval: 10s
|
||||
poll_interval: 10s
|
||||
storage:
|
||||
type: local
|
||||
local:
|
||||
directory: /etc/loki/rules
|
||||
rule_path: /tmp/loki/rules-temp
|
||||
enable_api: true
|
||||
enable_alertmanager_v2: true
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-08-01
|
||||
store: boltdb-shipper
|
||||
object_store: filesystem
|
||||
schema: v11
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
common:
|
||||
path_prefix: /tmp/loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /tmp/loki/chunks
|
||||
rules_directory: /tmp/loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
instance_addr: 127.0.0.1
|
||||
kvstore:
|
||||
store: inmemory
|
11
6-1-loki-alerts/promtail.yml
Normal file
11
6-1-loki-alerts/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
||||
clients:
|
||||
- url: http://loki:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: flogs
|
||||
__path__: /tmp/log/*.log
|
8
6-1-loki-alerts/provisioning/datasources/loki.yml
Normal file
8
6-1-loki-alerts/provisioning/datasources/loki.yml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: http://loki:3100
|
||||
isDefault: true
|
||||
editable: true
|
10
6-1-loki-alerts/rules.yml
Normal file
10
6-1-loki-alerts/rules.yml
Normal file
@ -0,0 +1,10 @@
|
||||
groups:
|
||||
- name: credentials_leak
|
||||
rules:
|
||||
- alert: http-credentials-leaked
|
||||
annotations:
|
||||
message: "{{ $labels.job }} is leaking http basic auth credentials."
|
||||
expr: 'sum by (job) (count_over_time({job="myservice"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
|
||||
for: 10s
|
||||
labels:
|
||||
severity: critical
|
30
6-2-grafana-alerts/docker-compose.yml
Normal file
30
6-2-grafana-alerts/docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
grafana:
|
||||
image: "grafana/grafana:8.4.2"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./provisioning:/etc/grafana/provisioning
|
||||
environment:
|
||||
- GF_SMTP_ENABLED=true
|
||||
- GF_SMTP_HOST=mail:1025
|
||||
|
||||
loki:
|
||||
image: "grafana/loki:2.4.2"
|
||||
command: --config.file=/mnt/config/loki.yml
|
||||
ports:
|
||||
- "3100:3100"
|
||||
volumes:
|
||||
- ./loki.yml:/mnt/config/loki.yml
|
||||
- ./rules.yml:/etc/loki/rules/fake/rules.yml
|
||||
|
||||
mail:
|
||||
image: "dockage/mailcatcher:0.7.1"
|
||||
ports:
|
||||
- "1080:1080"
|
||||
- "1025:1025"
|
||||
|
||||
volumes:
|
||||
logs_dir:
|
38
6-2-grafana-alerts/loki.yml
Normal file
38
6-2-grafana-alerts/loki.yml
Normal file
@ -0,0 +1,38 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
http_listen_address: 0.0.0.0
|
||||
|
||||
ruler:
|
||||
evaluation_interval: 10s
|
||||
poll_interval: 10s
|
||||
storage:
|
||||
type: local
|
||||
local:
|
||||
directory: /etc/loki/rules
|
||||
rule_path: /tmp/loki/rules-temp
|
||||
enable_api: true
|
||||
enable_alertmanager_v2: true
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-08-01
|
||||
store: boltdb-shipper
|
||||
object_store: filesystem
|
||||
schema: v11
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
common:
|
||||
path_prefix: /tmp/loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /tmp/loki/chunks
|
||||
rules_directory: /tmp/loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
instance_addr: 127.0.0.1
|
||||
kvstore:
|
||||
store: inmemory
|
11
6-2-grafana-alerts/promtail.yml
Normal file
11
6-2-grafana-alerts/promtail.yml
Normal file
@ -0,0 +1,11 @@
|
||||
clients:
|
||||
- url: http://loki:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: flog
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: flogs
|
||||
__path__: /tmp/log/*.log
|
8
6-2-grafana-alerts/provisioning/datasources/loki.yml
Normal file
8
6-2-grafana-alerts/provisioning/datasources/loki.yml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: http://loki:3100
|
||||
isDefault: true
|
||||
editable: true
|
10
6-2-grafana-alerts/rules.yml
Normal file
10
6-2-grafana-alerts/rules.yml
Normal file
@ -0,0 +1,10 @@
|
||||
groups:
|
||||
- name: credentials_leak
|
||||
rules:
|
||||
- alert: http-credentials-leaked
|
||||
annotations:
|
||||
message: "{{ $labels.job }} is leaking http basic auth credentials."
|
||||
expr: 'sum by (job) (count_over_time({job="myservice"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
|
||||
for: 10s
|
||||
labels:
|
||||
severity: critical
|
Loading…
Reference in New Issue
Block a user