From d3b8f9281fc748bae269e4f8191ea7bc4f7ac90f Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Tue, 6 Jan 2026 13:15:10 +0100 Subject: [PATCH] feat(regexp): support grafana dashboards --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++- grafana-dashboards.json | 12 ++++++ regexp.json | 9 ----- 3 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 grafana-dashboards.json diff --git a/README.md b/README.md index 47a5883..3376157 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,87 @@ # renovate-config This project contains configuration presets for renovate, a bot to update dependencies. These presets can be integrated -into the `renovate.json` of the respective git project using the `extends` attribute. \ No newline at end of file +into the `renovate.json` of the respective git project using the `extends` attribute. + +## How to + +### regexp + +Contains regular expressions to search for inline configurations of renovate. For example in `.sh` or `Makefile` files. +A regular expression is applied to extract an inline configuration. The regular expression is really complex. For this +reason, it is reproduced on [regexp101.com](https://regex101.com/r/H7bNqj) for the purpose of standardization. + +Here are further examples how to use the regexp inline configuration. + +#### container image version + +A shell script that executes a container image. The version of the container image should be maintained in the shell +script. + +```bash +#!/bin/bash + +VERSION="3.21.1" # renovate: datasource=docker registryUrl=https://docker.io depName=library/alpine + +docker run --rm --entrypoint /bin/sh docker.io/library/alpine:${VERSION} -c "echo foo bar" +``` + +#### github releases and tags + +A PKGBUILD file for the Arch Linux User Repository (AUR) whose version is to be updated based on GitHub releases. + +> [!NOTE] +> The concrete example can be found in [volker-raschek/rpm-builder-aur](https://github.com/volker-raschek/rpm-builder-pkg/blob/master/PKGBUILD#L4). + +```sh +pkgname=rpm-builder +pkgver=v0.8.1 # renovate: datasource=github-releases depName=Richterrettich/rpm-builder +pkgrel=1 +``` + +#### extract version + +The version of Postfixadmin is maintained in a Makefile. As source should be used github tags, but their tags does not +follow an official standard like PEP404 or semver. They use `postfixadmin-`. The `extractVersion` pattern is +used to extract the version of the git tag. + +> [!NOTE] +> The concrete example can be found in [volker-raschek/postfixadmin-docker](https://github.com/volker-raschek/postfixadmin-docker/blob/324d532b696bf7f6007375bb3601d204ad5f4e45/Makefile#L3) + +```Makefile +# POSTFIXADMIN_VERSION +POSTFIXADMIN_VERSION?=3.3.15 # renovate: datasource=github-tags depName=postfixadmin/postfixadmin extractVersion='postfixadmin-(?\d+\.\d+\.\d+)$' +``` + +#### grafana-dashboards + +Grafana supports importing of dashboards via its sidecar container in kubernetes environments. The import can be +specified via the `values.yaml` file of kube-prometheus stack. The `revision` must be updated, if the maintainer of the +dashboard has released a new revision. This can be automatically be updated via renovate. Below is an excerpt of the +`values.yaml` file. + +> [!NOTE] +> The datasource `custom.grafana-dashboards` is a custom implemented datasource. The renovate project does not support +> updating grafana dashboards by default, because the API does not provide the required minimum set of attributes. +> +> Further information can be found on the discussion [Grafana Dashboard +> revisions](https://github.com/renovatebot/renovate/discussions/16624#discussioncomment-3169468). + +The `gnetId` and `revision` must be extracted from [Grafana.com](https://grafana.com/grafana/dashboards/). + +> [!IMPORTANT] +> The defined regexp in `regexp.json` does not support that `depName` contains any spaces! + +```yaml +grafana: + dashboards: + default: + 1860-node-exporter-full: + gnetId: 1860 + revision: 31 # renovate: datasource=custom.grafana-dashboards depName='Node-Exporter-Full' packageName=1860 versioning='regex:^(?\d+)$' + datasource: Prometheus + 15760-kubernetes-views-pods: + gnetId: 15760 + revision: 19 # renovate: datasource=custom.grafana-dashboards depName='Kubernetes-Views-Pods' packageName=15760 versioning='regex:^(?\d+)$' + datasource: Prometheus +``` diff --git a/grafana-dashboards.json b/grafana-dashboards.json new file mode 100644 index 0000000..cc143bc --- /dev/null +++ b/grafana-dashboards.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "customDatasources": { + "grafana-dashboards": { + "defaultRegistryUrlTemplate": "https://grafana.com/api/dashboards/{{ packageName }}", + "format": "json", + "transformTemplates": [ + "{\"releases\": [{\"version\": $string(revision)}], \"homepage\": \"https://grafana.com/dashboards/$string(id)\", \"sourceUrl\": \"https://grafana.com/dashboards/$string(id)\"}" + ] + } + } +} \ No newline at end of file diff --git a/regexp.json b/regexp.json index 1b8ce1f..c41d78c 100644 --- a/regexp.json +++ b/regexp.json @@ -1,14 +1,5 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "customDatasources": { - "grafana-dashboards": { - "defaultRegistryUrlTemplate": "https://grafana.com/api/dashboards/{{ packageName }}", - "format": "json", - "transformTemplates": [ - "{\"releases\": [{\"version\": $string(revision)}], \"homepage\": \"https://grafana.com/dashboards/$string(id)\", \"sourceUrl\": \"https://grafana.com/dashboards/$string(id)\"}" - ] - } - }, "customManagers": [ { "customType": "regex",