Skip to content

Commit 693d710

Browse files
authored
Pint lint: fail on warnings (#1415)
* Make pint lint more strict (fail on warnings and show info). * fix pgbouncer ci * fix hbase * Fix tomcat * Fail on jsonnet lint diff * add exception
1 parent 5cd2279 commit 693d710

File tree

13 files changed

+62
-56
lines changed

13 files changed

+62
-56
lines changed

.github/workflows/test-mixins.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292

9393
- name: Check for unexpected changes in generated files
9494
working-directory: ./${{ matrix.mixin }}
95-
run: "make && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
95+
run: "make dashboards_out prometheus_alerts.yaml prometheus_rules.yaml && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
9696

9797
- name: Wait for Grafana and validate dashboards
9898
working-directory: ./${{ matrix.mixin }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ lint-mixins:
6767
fi; \
6868
if [ -d "$$d/prometheus_rules_out" ]; then \
6969
echo "Running pint..."; \
70-
pint lint "$$d/prometheus_rules_out/"; \
70+
pint lint --min-severity=info --fail-on=warning "$$d/prometheus_rules_out/"; \
7171
if [ $$? -ne 0 ]; then \
7272
RESULT=1; \
7373
fi; \

Makefile_mixin

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 1 --string-style s --comment-style s
1+
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
22

33
.PHONY: all
44
all: build dashboards_out prometheus_alerts.yaml prometheus_rules.yaml test
@@ -18,15 +18,16 @@ fmt:
1818

1919
.PHONY: lint
2020
lint: build lint-pint
21-
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
21+
@set -e; \
22+
find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
2223
while read f; do \
23-
$(JSONNET_FMT) "$$f" | diff -u "$$f" -; \
24-
done
24+
$(JSONNET_FMT) "$$f" | diff -u "$$f" - || exit 1; \
25+
done; \
2526
mixtool lint mixin.libsonnet
2627

2728
.PHONY: lint-pint
2829
lint-pint: prometheus_alerts.yaml prometheus_rules.yaml
29-
pint lint prometheus_rules_out/
30+
pint lint --min-severity=info --fail-on=warning prometheus_rules_out/
3031

3132
dashboards_out: mixin.libsonnet $(wildcard **/*.libsonnet) $(wildcard **/*.jsonnet) $(wildcard panels/*) $(wildcard signals/*)
3233
@mkdir -p dashboards_out

apache-hbase-mixin/config.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
_config+:: {
3-
filterSelector: 'job=~"integrations/apache-hbase"',
3+
filterSelector: 'job="integrations/apache-hbase"',
44

55
dashboardTags: ['apache-hbase-mixin'],
66
dashboardPeriod: 'now-30m',

apache-hbase-mixin/prometheus_rules_out/prometheus_alerts.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apache-tomcat-mixin/config.libsonnet

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
ApacheTomcatAlertsWarningProcessingTime: 300, //ms
1313

1414
// used in alerts:
15-
filteringSelector: 'job=~"integrations/tomcat"',
15+
filteringSelector: 'job="integrations/tomcat"',
1616
groupLabels: if self.enableMultiCluster then ['job', 'cluster'] else ['job'],
1717
instanceLabels: ['instance'],
1818

19-
2019
enableLokiLogs: true,
2120
enableMultiCluster: false,
2221
multiclusterSelector: 'job=~"$job"',

apache-tomcat-mixin/prometheus_rules_out/prometheus_alerts.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pgbouncer-mixin/.pint.hcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
checks {
3+
//using without() aggregation function
4+
disabled = ["promql/fragile"]
5+
}
6+

pgbouncer-mixin/dashboards_out/clusterOverview

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"type": "prometheus",
5757
"uid": "${prometheus_datasource}"
5858
},
59-
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, pgbouncer_pools_client_active_connections{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"})",
59+
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, pgbouncer_pools_client_active_connections{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"})",
6060
"legendFormat": "{{pgbouncer_cluster}} - {{instance}} - {{database}}"
6161
}
6262
],
@@ -124,7 +124,7 @@
124124
"type": "prometheus",
125125
"uid": "${prometheus_datasource}"
126126
},
127-
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_queries_pooled_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"}[$__rate_interval]))",
127+
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_queries_pooled_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"}[$__rate_interval]))",
128128
"legendFormat": "{{pgbouncer_cluster}} - {{instance}} - {{database}}"
129129
}
130130
],
@@ -173,7 +173,7 @@
173173
"type": "prometheus",
174174
"uid": "${prometheus_datasource}"
175175
},
176-
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, 1000 * increase(pgbouncer_stats_queries_duration_seconds_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"}[$__interval:]) / clamp_min(increase(pgbouncer_stats_queries_pooled_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"}[$__interval:]), 1))",
176+
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, 1000 * increase(pgbouncer_stats_queries_duration_seconds_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"}[$__interval:]) / clamp_min(increase(pgbouncer_stats_queries_pooled_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"}[$__interval:]), 1))",
177177
"legendFormat": "{{pgbouncer_cluster}} - {{instance}} - {{database}}"
178178
}
179179
],
@@ -223,15 +223,15 @@
223223
"type": "prometheus",
224224
"uid": "${prometheus_datasource}"
225225
},
226-
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_received_bytes_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"}[$__rate_interval]))",
226+
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_received_bytes_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"}[$__rate_interval]))",
227227
"legendFormat": "{{pgbouncer_cluster}} - {{instance}} - {{database}} - received"
228228
},
229229
{
230230
"datasource": {
231231
"type": "prometheus",
232232
"uid": "${prometheus_datasource}"
233233
},
234-
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_sent_bytes_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=~\"integrations/pgbouncer\"}[$__rate_interval]))",
234+
"expr": "topk by(database, instance, pgbouncer_cluster)($top_database_count, rate(pgbouncer_stats_sent_bytes_total{job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",job=\"integrations/pgbouncer\"}[$__rate_interval]))",
235235
"legendFormat": "{{pgbouncer_cluster}} - {{instance}} - {{database}} - sent"
236236
}
237237
],
@@ -263,7 +263,7 @@
263263
"label": "Job",
264264
"multi": true,
265265
"name": "job",
266-
"query": "label_values(pgbouncer_databases_current_connections{job=~\"integrations/pgbouncer\"}, job)",
266+
"query": "label_values(pgbouncer_databases_current_connections{job=\"integrations/pgbouncer\"}, job)",
267267
"refresh": 2,
268268
"sort": 1,
269269
"type": "query"
@@ -278,7 +278,7 @@
278278
"label": "Pgbouncer_cluster",
279279
"multi": true,
280280
"name": "pgbouncer_cluster",
281-
"query": "label_values(pgbouncer_databases_current_connections{job=~\"integrations/pgbouncer\",job=~\"$job\"}, pgbouncer_cluster)",
281+
"query": "label_values(pgbouncer_databases_current_connections{job=\"integrations/pgbouncer\",job=~\"$job\"}, pgbouncer_cluster)",
282282
"refresh": 2,
283283
"sort": 1,
284284
"type": "query"

pgbouncer-mixin/dashboards_out/logs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"type": "loki",
161161
"uid": "${loki_datasource}"
162162
},
163-
"expr": "sum by (level) (count_over_time({job=~\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\",level=~\"$level\"}\n|~ \"$regex_search\"\n\n[$__auto]))\n",
163+
"expr": "sum by (level) (count_over_time({job=\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\",level=~\"$level\"}\n|~ \"$regex_search\"\n\n[$__auto]))\n",
164164
"legendFormat": "{{ level }}"
165165
}
166166
],
@@ -202,7 +202,7 @@
202202
"type": "loki",
203203
"uid": "${loki_datasource}"
204204
},
205-
"expr": "{job=~\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\",level=~\"$level\"} \n|~ \"$regex_search\"\n\n\n"
205+
"expr": "{job=\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\",level=~\"$level\"} \n|~ \"$regex_search\"\n\n\n"
206206
}
207207
],
208208
"title": "Logs",
@@ -233,7 +233,7 @@
233233
"label": "Job",
234234
"multi": true,
235235
"name": "job",
236-
"query": "label_values({job=~\"integrations/pgbouncer\"}, job)",
236+
"query": "label_values({job=\"integrations/pgbouncer\"}, job)",
237237
"refresh": 2,
238238
"sort": 1,
239239
"type": "query"
@@ -248,7 +248,7 @@
248248
"label": "Pgbouncer_cluster",
249249
"multi": true,
250250
"name": "pgbouncer_cluster",
251-
"query": "label_values({job=~\"integrations/pgbouncer\",job=~\"$job\"}, pgbouncer_cluster)",
251+
"query": "label_values({job=\"integrations/pgbouncer\",job=~\"$job\"}, pgbouncer_cluster)",
252252
"refresh": 2,
253253
"sort": 1,
254254
"type": "query"
@@ -263,7 +263,7 @@
263263
"label": "Instance",
264264
"multi": true,
265265
"name": "instance",
266-
"query": "label_values({job=~\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\"}, instance)",
266+
"query": "label_values({job=\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\"}, instance)",
267267
"refresh": 2,
268268
"sort": 1,
269269
"type": "query"
@@ -278,7 +278,7 @@
278278
"label": "Level",
279279
"multi": true,
280280
"name": "level",
281-
"query": "label_values({job=~\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\"}, level)",
281+
"query": "label_values({job=\"integrations/pgbouncer\",job=~\"$job\",pgbouncer_cluster=~\"$pgbouncer_cluster\",instance=~\"$instance\"}, level)",
282282
"refresh": 2,
283283
"sort": 1,
284284
"type": "query"

0 commit comments

Comments
 (0)