Skip to content

Commit

Permalink
Use mixins
Browse files Browse the repository at this point in the history
Signed-off-by: QuentinBisson <[email protected]>
  • Loading branch information
QuentinBisson committed Apr 11, 2024
1 parent efab778 commit 8990c57
Show file tree
Hide file tree
Showing 14 changed files with 16,645 additions and 16,829 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,136 changes: 1,068 additions & 1,068 deletions helm/dashboards/charts/private_dashboards_al/dashboards/shared/private/loki-logs.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions loki/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendor/
dashboards_out/
alerts.yaml
rules.yaml
jsonnetfile.*

17 changes: 17 additions & 0 deletions loki/mixin.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local loki = import 'loki-mixin/mixin-ssd.libsonnet';

loki{
_config+:: {
tags: [
"owner:team-atlas",
"topic:observability",
"component:loki"
],

per_cluster_label: 'cluster_id',

canary+: {
enabled: true,
},
},
}
29 changes: 15 additions & 14 deletions loki/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@

# Update Loki mixins from upstream
#
# This script is used to update the Loki mixins from the upstream repository.
#
# Usage:
# ./loki/update.sh from the root of the repository

set -e

TAG="helm-loki-5.47.2"
helmDir="$(pwd)/helm/dashboards/charts/private_dashboards_al/dashboards/shared/private"

tmpDir="$(mktemp -d)"
cp loki/mixin.libsonnet "$tmpDir"
cd "$tmpDir"
jb init
jb install https://github.com/grafana/loki/production/loki-mixin@$TAG
mixtool generate all mixin.libsonnet

git clone --depth 1 --single-branch -b "$TAG" --no-tags -q [email protected]:grafana/loki.git "$tmpDir"

ls -l "$tmpDir"/production/loki-mixin-compiled-ssd/dashboards

rm -rf ./output
mkdir -p ./output

for file in "$tmpDir"/production/loki-mixin-compiled-ssd/dashboards/*; do
for file in dashboards_out/*; do
# Process each file here
echo "$file"

# replaces cluster with cluster_id in queries and expr, then adds loki- prefix to uid
jq '.uid = "loki-" + .uid | .templating.list[].query |= gsub(", cluster\\)"; ", cluster_id)") | .templating.list[].query |= gsub("cluster=~\\\"\\$cluster\\\""; "cluster_id=~\"$cluster_id\"") | .templating.list[].query |= gsub("cluster=\\\"\\$cluster\\\""; "cluster_id=\"$cluster_id\"") | .rows[].panels[].targets[].expr |= gsub("cluster=~\\\"\\$cluster\\\""; "cluster_id=~\"$cluster_id\"") | .rows[].panels[].targets[].expr |= gsub("cluster=\\\"\\$cluster\\\""; "cluster_id=\"$cluster_id\"") | .tags |= ["owner:team-atlas", "topic:observability", "component:loki"] | .links[].tags |= ["owner:team-atlas", "topic:observability", "component:loki"]' "$file" > "./output/$(basename "$file")"
# adds loki- prefix to uid
jq '.uid = "loki-" + .uid' "$file" > "$$file.out" && mv "$$file.out" "$$file"

echo "Copying dashboard to $helmDir"
cp "$file" "$helmDir"
done

cp ./output/* helm/dashboards/charts/private_dashboards_al/dashboards/shared/private


0 comments on commit 8990c57

Please sign in to comment.