feat(regexp): support grafana dashboards

This commit is contained in:
2026-01-06 13:15:10 +01:00
parent d4b3feb347
commit d3b8f9281f
3 changed files with 96 additions and 10 deletions

View File

@@ -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.
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-<semver>`. 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-(?<version>\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:^(?<major>\d+)$'
datasource: Prometheus
15760-kubernetes-views-pods:
gnetId: 15760
revision: 19 # renovate: datasource=custom.grafana-dashboards depName='Kubernetes-Views-Pods' packageName=15760 versioning='regex:^(?<major>\d+)$'
datasource: Prometheus
```

12
grafana-dashboards.json Normal file
View File

@@ -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)\"}"
]
}
}
}

View File

@@ -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",