🚀 loki

This commit is contained in:
auricom
2023-11-15 19:38:24 +01:00
parent 6ff46ee7ae
commit b7865afffb
8 changed files with 177 additions and 213 deletions

View File

@@ -9,4 +9,5 @@ resources:
- ./gatus/ks.yaml
- ./grafana/ks.yaml
- ./kube-prometheus-stack/ks.yaml
- ./loki/ks.yaml
- ./thanos/ks.yaml

View File

@@ -0,0 +1,22 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-gatus-ep
namespace: monitoring
labels:
gatus.io/enabled: "true"
data:
config.yaml: |
endpoints:
- name: loki
group: internal
url: https://loki.${SECRET_CLUSTER_DOMAIN}
interval: 1m
client:
dns-resolver: tcp://1.1.1.1:53
insecure: true
conditions:
- "[STATUS] == 200"
alerts:
- type: pushover

View File

@@ -0,0 +1,184 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/helmrelease-helm-v2beta1.json
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: loki
namespace: monitoring
spec:
interval: 30m
timeout: 15m
chart:
spec:
chart: loki
version: 5.36.3
sourceRef:
kind: HelmRepository
name: grafana
namespace: flux-system
maxHistory: 2
install:
remediation:
retries: 3
upgrade:
cleanupOnFail: true
remediation:
retries: 3
uninstall:
keepHistory: false
dependsOn:
- name: rook-ceph-cluster
namespace: rook-ceph
values:
loki:
structuredConfig:
auth_enabled: false
server:
log_level: info
http_listen_port: 3100
grpc_listen_port: 9095
memberlist:
join_members: ["loki-memberlist"]
limits_config:
retention_period: 14d
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
max_cache_freshness_per_query: 10m
split_queries_by_interval: 15m
ingestion_rate_mb: 50
ingestion_burst_size_mb: 1000
per_stream_rate_limit: 5MB
per_stream_rate_limit_burst: 20MB
shard_streams:
enabled: true
schema_config:
configs:
- from: "2022-01-11" # quote
store: boltdb-shipper
object_store: s3
schema: v12
index:
prefix: loki_index_
period: 24h
common:
path_prefix: /var/loki
replication_factor: 2
storage:
s3:
s3: null
insecure: true
s3forcepathstyle: true
ring:
kvstore:
store: memberlist
ruler:
enable_api: true
enable_alertmanager_v2: true
alertmanager_url: http://alertmanager-operated.monitoring.svc.cluster.local:9093
storage:
type: local
local:
directory: /rules
rule_path: /tmp/scratch
ring:
kvstore:
store: memberlist
distributor:
ring:
kvstore:
store: memberlist
compactor:
working_directory: /var/loki/boltdb-shipper-compactor
shared_store: s3
compaction_interval: 10m
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
ingester:
max_chunk_age: 1h
lifecycler:
ring:
kvstore:
store: memberlist
analytics:
reporting_enabled: false
gateway:
replicas: 2
image:
registry: ghcr.io
ingress:
enabled: true
ingressClassName: "nginx"
annotations:
hajimari.io/enable: "false"
hosts:
- host: &host loki.devbu.io
paths:
- path: /
pathType: Prefix
tls:
- hosts:
- *host
read:
replicas: 2
persistence:
storageClass: local-path
extraVolumeMounts:
- name: rules
mountPath: /rules
extraVolumes:
- name: rules
emptyDir: {}
write:
replicas: 2
persistence:
storageClass: local-path
backend:
replicas: 2
persistence:
storageClass: local-path
extraVolumeMounts:
- name: rules
mountPath: /rules/fake
- name: scratch
mountPath: /tmp/scratch
extraVolumes:
- name: rules
configMap:
name: loki-alerting-rules
- name: scratch
emptyDir: {}
monitoring:
dashboards:
annotations:
grafana_folder: Loki
serviceMonitor:
enabled: false
metricsInstance:
enabled: false
selfMonitoring:
enabled: false
grafanaAgent:
installOperator: false
lokiCanary:
enabled: false
test:
enabled: false
valuesFrom:
- targetPath: loki.structuredConfig.common.storage.s3.bucketnames
kind: ConfigMap
name: loki-bucket
valuesKey: BUCKET_NAME
- targetPath: loki.structuredConfig.common.storage.s3.endpoint
kind: ConfigMap
name: loki-bucket
valuesKey: BUCKET_HOST
- targetPath: loki.structuredConfig.common.storage.s3.access_key_id
kind: Secret
name: loki-bucket
valuesKey: AWS_ACCESS_KEY_ID
- targetPath: loki.structuredConfig.common.storage.s3.secret_access_key
kind: Secret
name: loki-bucket
valuesKey: AWS_SECRET_ACCESS_KEY

View File

@@ -0,0 +1,14 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/kustomization.json
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: monitoring
resources:
- ./helmrelease.yaml
- ./objectbucketclaim.yaml
configMapGenerator:
- name: loki-alerting-rules
files:
- loki-alerting-rules.yaml=./rules/loki-alerting-rules.yaml
generatorOptions:
disableNameSuffixHash: true

View File

@@ -0,0 +1,9 @@
---
apiVersion: objectbucket.io/v1alpha1
kind: ObjectBucketClaim
metadata:
name: loki-bucket
namespace: monitoring
spec:
bucketName: loki
storageClassName: rook-ceph-bucket

View File

@@ -0,0 +1,79 @@
---
groups:
- name: smart
rules:
- alert: SMARTFailure
expr: |
sum by (hostname) (count_over_time({hostname=~".+"} | json | _SYSTEMD_UNIT = "smartmontools.service" !~ "(?i)previous self-test completed without error" !~ "(?i)Prefailure" |~ "(?i)(error|fail)"[2m])) > 0
for: 2m
labels:
severity: critical
category: logs
annotations:
hostname: "{{ $labels.hostname }}"
summary: "{{ $labels.hostname }} has reported SMART failures"
- name: zigbee2mqtt
rules:
- alert: ZigbeeMQTTUnreachable
expr: |
sum(count_over_time({app="zigbee2mqtt"} |~ "(?i)not connected to mqtt server"[2m])) > 0
for: 2m
labels:
severity: critical
category: logs
annotations:
app: "{{ $labels.app }}"
summary: "{{ $labels.app }} is unable to reach MQTT"
- name: zwave-js-ui
rules:
- alert: ZwaveMQTTUnreachable
expr: |
sum(count_over_time({app="zwave-js-ui"} |~ "(?i)error while connecting mqtt"[2m])) > 0
for: 2m
labels:
severity: critical
category: logs
annotations:
app: "{{ $labels.app }}"
summary: "{{ $labels.app }} is unable to reach MQTT"
- name: frigate
rules:
- alert: FrigateMQTTUnreachable
expr: |
sum(count_over_time({app="frigate"} |~ "(?i)unable to connect to mqtt server"[2m])) > 0
for: 2m
labels:
severity: critical
category: logs
annotations:
app: "{{ $labels.app }}"
summary: "{{ $labels.app }} is unable to reach MQTT"
- name: home-assistant
rules:
- alert: HomeAssistantPostgresUnreachable
expr: |
sum by (app) (count_over_time({app="home-assistant"} |~ "(?i)error in database connectivity"[2m])) > 0
for: 2m
labels:
severity: critical
category: logs
annotations:
app: "{{ $labels.app }}"
summary: "{{ $labels.app }} is unable to connect to postgres"
- name: bazarr
rules:
- alert: BazarrJobRaisedException
expr: |
sum by (app) (count_over_time({app="bazarr"} |~ "(?i)Job(.+)Update(.+)from(.+)raised an exception"[2m])) > 0
for: 2m
labels:
severity: warning
category: logs
annotations:
app: "{{ $labels.app }}"
summary: "{{ $labels.app }} is raising job exceptions"

View File

@@ -0,0 +1,20 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: cluster-apps-loki
namespace: flux-system
labels:
substitution.flux.home.arpa/enabled: "true"
spec:
dependsOn:
- name: cluster-apps-external-secrets-stores
path: ./kubernetes/apps/monitoring/loki/app
prune: true
sourceRef:
kind: GitRepository
name: home-ops-kubernetes
interval: 30m
retryInterval: 1m
timeout: 3m