Skip to content

Commit

Permalink
Add yaml linting step to helm ci (grafana#8822)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:

Adds a yaml linting step for the included rules in the loki helm chart.
Only way I could think to enforce the comma line ending was to require
qutoes around string, otherwise the linter cannot tell if the comma is
just part of the string.
  • Loading branch information
trevorwhitney authored Mar 17, 2023
1 parent 9688f83 commit a4d06ac
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/helm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
exit 1
fi
- name: Lint Yaml
run: make helm-lint

- name: Lint Code Base
uses: docker://github/super-linter:v3.12.0
env:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.PHONY: validate-example-configs generate-example-config-doc check-example-config-doc
.PHONY: clean clean-protos
.PHONY: k3d-loki k3d-enterprise-logs k3d-down
.PHONY: helm-test helm-lint

SHELL = /usr/bin/env bash -o pipefail

Expand Down Expand Up @@ -160,7 +161,7 @@ cmd/loki-canary/loki-canary:
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)

###############
# Helm-Test #
# Helm #
###############
.PHONY: production/helm/loki/src/helm-test/helm-test
helm-test: production/helm/loki/src/helm-test/helm-test
Expand All @@ -169,6 +170,9 @@ helm-test: production/helm/loki/src/helm-test/helm-test
production/helm/loki/src/helm-test/helm-test:
CGO_ENABLED=0 go test $(GO_FLAGS) --tags=helm_test -c -o $@ ./$(@D)

helm-lint:
$(MAKE) -BC production/helm/loki lint

#################
# Loki-QueryTee #
#################
Expand Down
7 changes: 7 additions & 0 deletions production/helm/loki/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DEFAULT_GOAL := all
.PHONY: lint lint-yaml

lint: lint-yaml

lint-yaml:
yamllint -c $(CURDIR)/src/.yamllint.yaml $(CURDIR)/src
4 changes: 4 additions & 0 deletions production/helm/loki/src/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
rules:
quoted-strings:
required: true
103 changes: 52 additions & 51 deletions production/helm/loki/src/alerts.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
---
groups:
- name: loki_alerts
rules:
- alert: LokiRequestErrors
annotations:
message: |
{{ $labels.job }} {{ $labels.route }} is experiencing {{ printf "%.2f" $value }}% errors.
expr: |
100 * sum(rate(loki_request_duration_seconds_count{status_code=~"5.."}[2m])) by (namespace, job, route)
/
sum(rate(loki_request_duration_seconds_count[2m])) by (namespace, job, route)
> 10
for: 15m
labels:
severity: critical
- alert: LokiRequestPanics
annotations:
message: |
{{ $labels.job }} is experiencing {{ printf "%.2f" $value }}% increase of panics.
expr: |
sum(increase(loki_panic_total[10m])) by (namespace, job) > 0
labels:
severity: critical
- alert: LokiRequestLatency
annotations:
message: |
{{ $labels.job }} {{ $labels.route }} is experiencing {{ printf "%.2f" $value }}s 99th percentile latency.
expr: |
namespace_job_route:loki_request_duration_seconds:99quantile{route!~"(?i).*tail.*"} > 1
for: 15m
labels:
severity: critical
- alert: LokiTooManyCompactorsRunning
annotations:
message: |
{{ $labels.cluster }} {{ $labels.namespace }} has had {{ printf "%.0f" $value }} compactors running for more than 5m. Only one compactor should run at a time.
expr: |
sum(loki_boltdb_shipper_compactor_running) by (namespace, cluster) > 1
for: 5m
labels:
severity: warning
- name: 'loki_canaries_alerts'
rules:
- alert: 'LokiCanaryLatency'
annotations:
message: |
{{ $labels.job }} is experiencing {{ printf "%.2f" $value }}s 99th percentile latency.
expr: |
histogram_quantile(0.99, sum(rate(loki_canary_response_latency_seconds_bucket[5m])) by (le, namespace, job)) > 5
for: '15m'
labels:
severity: 'warning'
- name: "loki_alerts"
rules:
- alert: "LokiRequestErrors"
annotations:
message: |
{{ $labels.job }} {{ $labels.route }} is experiencing {{ printf "%.2f" $value }}% errors.
expr: |
100 * sum(rate(loki_request_duration_seconds_count{status_code=~"5.."}[2m])) by (namespace, job, route)
/
sum(rate(loki_request_duration_seconds_count[2m])) by (namespace, job, route)
> 10
for: "15m"
labels:
severity: "critical"
- alert: "LokiRequestPanics"
annotations:
message: |
{{ $labels.job }} is experiencing {{ printf "%.2f" $value }}% increase of panics.
expr: |
sum(increase(loki_panic_total[10m])) by (namespace, job) > 0
labels:
severity: "critical"
- alert: "LokiRequestLatency"
annotations:
message: |
{{ $labels.job }} {{ $labels.route }} is experiencing {{ printf "%.2f" $value }}s 99th percentile latency.
expr: |
namespace_job_route:loki_request_duration_seconds:99quantile{route!~"(?i).*tail.*"} > 1
for: "15m"
labels:
severity: "critical"
- alert: "LokiTooManyCompactorsRunning"
annotations:
message: |
{{ $labels.cluster }} {{ $labels.namespace }} has had {{ printf "%.0f" $value }} compactors running for more than 5m. Only one compactor should run at a time.
expr: |
sum(loki_boltdb_shipper_compactor_running) by (namespace, cluster) > 1
for: "5m"
labels:
severity: "warning"
- name: "loki_canaries_alerts"
rules:
- alert: "LokiCanaryLatency"
annotations:
message: |
{{ $labels.job }} is experiencing {{ printf "%.2f" $value }}s 99th percentile latency.
expr: |
histogram_quantile(0.99, sum(rate(loki_canary_response_latency_seconds_bucket[5m])) by (le, namespace, job)) > 5
for: "15m"
labels:
severity: "warning"

0 comments on commit a4d06ac

Please sign in to comment.