Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 1a59317

Browse files
authored
Merge pull request #202 from grafana/mixtool
Use mixtool to build and lint the mixin.
2 parents 7b0ec7e + fe68dc3 commit 1a59317

20 files changed

+37
-39
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ workflows:
1111
jobs:
1212
lint:
1313
docker:
14-
- image: grafana/cortex-jsonnet-build-image:55f5699
14+
- image: grafana/cortex-jsonnet-build-image:8ce0de1
1515
steps:
1616
- checkout
1717
- run: make lint
1818

1919
build:
2020
docker:
21-
- image: grafana/cortex-jsonnet-build-image:55f5699
21+
- image: grafana/cortex-jsonnet-build-image:8ce0de1
2222
steps:
2323
- checkout
2424
- run: make build-mixin
2525
- store_artifacts:
26-
path: cortex-mixin.zip
26+
path: cortex-mixin/cortex-mixin.zip
2727
test-readme:
2828
docker:
29-
- image: grafana/cortex-jsonnet-build-image:55f5699
29+
- image: grafana/cortex-jsonnet-build-image:8ce0de1
3030
steps:
3131
- checkout
3232
- run: make test-readme

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
JSONNET_FMT := jsonnetfmt
44

5-
lint:
5+
lint: lint-mixin
66
@RESULT=0; \
77
for f in $$(find . -name '*.libsonnet' -print -o -name '*.jsonnet' -print); do \
88
$(JSONNET_FMT) -- "$$f" | diff -u "$$f" -; \
99
RESULT=$$(($$RESULT + $$?)); \
1010
done; \
11-
exit $$RESULT
11+
RESULT=$$(($$RESULT + $$?)); \
12+
13+
lint-mixin:
14+
cd cortex-mixin && \
15+
jb install && \
16+
mixtool lint mixin.libsonnet
1217

1318
fmt:
1419
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
@@ -24,10 +29,8 @@ build-mixin:
2429
cd cortex-mixin && \
2530
rm -rf out && mkdir out && \
2631
jb install && \
27-
jsonnet -J vendor -S dashboards.jsonnet -m out/ && \
28-
jsonnet -J vendor -S recording_rules.jsonnet > out/rules.yaml && \
29-
jsonnet -J vendor -S alerts.jsonnet > out/alerts.yaml
30-
zip -r cortex-mixin.zip cortex-mixin/out
32+
mixtool generate all --output-alerts out/alerts.yaml --output-rules out/rules.yaml --directory out/dashboards mixin.libsonnet && \
33+
zip -r cortex-mixin.zip out
3134

3235
test-readme:
3336
rm -rf test-readme && \

build-image/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ RUN curl -fSL -o "/usr/bin/tk" "https://github.com/grafana/tanka/releases/downlo
2525
RUN echo "${TANKA_CHECKSUM}" | sha256sum -c || (printf "wanted: %s\n got: %s\n" "${TANKA_CHECKSUM}" "$(sha256sum /usr/bin/tk)"; exit 1)
2626
RUN chmod +x /usr/bin/tk
2727

28+
# Build mixtool
29+
FROM golang:1.15-alpine AS mixtool-builder
30+
RUN GO111MODULE=on go get github.com/monitoring-mixins/mixtool/cmd/mixtool@59d44357240d
31+
2832
FROM alpine:3.11
2933
RUN apk add --no-cache git make libgcc libstdc++ zip
3034
COPY --from=jsonnet-builder /usr/bin/jsonnetfmt /usr/bin
3135
COPY --from=jsonnet-builder /usr/bin/jsonnet /usr/bin
3236
COPY --from=jb-builder /usr/bin/jb /usr/bin
3337
COPY --from=tk-builder /usr/bin/tk /usr/bin
38+
COPY --from=mixtool-builder /go/bin/mixtool /usr/bin

cortex-mixin/alerts.jsonnet

Lines changed: 0 additions & 3 deletions
This file was deleted.

cortex-mixin/dashboards.jsonnet

Lines changed: 0 additions & 6 deletions
This file was deleted.

cortex-mixin/dashboards/chunks.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
22

33
(import 'dashboard-utils.libsonnet') {
44
'cortex-chunks.json':
5-
$.dashboard('Cortex / Chunks')
5+
($.dashboard('Cortex / Chunks') + { uid: 'a56a3fa6284064eb392a115f3acbf744' })
66
.addClusterSelectorTemplates()
77
.addRow(
88
$.row('Active Series / Chunks')
@@ -52,7 +52,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
5252
),
5353

5454
'cortex-wal.json':
55-
$.dashboard('Cortex / WAL')
55+
($.dashboard('Cortex / WAL') + { uid: 'd4fb924cdc1581cd8e870e3eb0110bda' })
5656
.addClusterSelectorTemplates()
5757
.addRow(
5858
$.row('')

cortex-mixin/dashboards/compactor-resources.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
66
ignoring(pod) group_right() (label_replace(count by(pod, instance, device) (container_fs_writes_bytes_total{%s,container="compactor",device!~".*sda.*"}), "device", "$1", "device", "/dev/(.*)") * 0)
77
||| % $.namespaceMatcher();
88

9-
$.dashboard('Cortex / Compactor Resources')
9+
($.dashboard('Cortex / Compactor Resources') + { uid: 'df9added6f1f4332f95848cca48ebd99' })
1010
.addClusterSelectorTemplates()
1111
.addRow(
1212
$.row('CPU and Memory')

cortex-mixin/dashboards/compactor.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
22

33
(import 'dashboard-utils.libsonnet') {
44
'cortex-compactor.json':
5-
$.dashboard('Cortex / Compactor')
5+
($.dashboard('Cortex / Compactor') + { uid: '9c408e1d55681ecb8a22c9fab46875cc' })
66
.addClusterSelectorTemplates()
77
.addRow(
88
$.row('Compactions')

cortex-mixin/dashboards/comparison.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
33
(import 'dashboard-utils.libsonnet')
44
{
55
'cortex-blocks-vs-chunks.json':
6-
$.dashboard('Cortex / Blocks vs Chunks')
6+
($.dashboard('Cortex / Blocks vs Chunks') + { uid: '0e2b4dd23df9921972e3fb554c0fc483' })
77
.addMultiTemplate('cluster', 'kube_pod_container_info{image=~".*cortex.*"}', 'cluster')
88
.addTemplate('blocks_namespace', 'kube_pod_container_info{image=~".*cortex.*"}', 'namespace')
99
.addTemplate('chunks_namespace', 'kube_pod_container_info{image=~".*cortex.*"}', 'namespace')

cortex-mixin/dashboards/config.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
33
(import 'dashboard-utils.libsonnet') {
44

55
'cortex-config.json':
6-
$.dashboard('Cortex / Config')
6+
($.dashboard('Cortex / Config') + { uid: '61bb048ced9817b2d3e07677fb1c6290' })
77
.addClusterSelectorTemplates()
88
.addRow(
99
$.row('Startup config file')

0 commit comments

Comments
 (0)