From fba3e847dc5ef8dea7cc8e38fba16fa544b2ba30 Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Thu, 26 May 2022 18:17:21 +1000 Subject: [PATCH] Check syntax of example configurations (#10753) * Check syntax of example configurations Fix a mistake in the hetzner and vultr configs. Also it's easier not to fight the build system, and this will lint example code, so ignore a lint issue in custom-sd. Signed-off-by: David Leadbeater * No need to import Makefile.common, it just complicates things Signed-off-by: David Leadbeater --- .circleci/config.yml | 1 + documentation/examples/Makefile | 20 +++++++++++++++++++ .../examples/custom-sd/adapter/adapter.go | 1 + documentation/examples/prometheus-hetzner.yml | 6 +++--- documentation/examples/prometheus-vultr.yml | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 documentation/examples/Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml index 5bbeecedf5..d6fd087558 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,7 @@ jobs: GO111MODULE: "on" - run: go test ./tsdb/ -test.tsdb-isolation=false - run: make -C documentation/examples/remote_storage + - run: make -C documentation/examples - prometheus/check_proto: version: "3.15.8" - prometheus/store_artifact: diff --git a/documentation/examples/Makefile b/documentation/examples/Makefile new file mode 100644 index 0000000000..4085155f80 --- /dev/null +++ b/documentation/examples/Makefile @@ -0,0 +1,20 @@ +# Copyright 2022 The Prometheus Authors +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.PHONY: all +all: check-examples-syntax + +.PHONY: check-examples-syntax +check-examples-syntax: prometheus-*.yml + @echo ">> check example configurations syntax" + @set -e; for file in $^; do ../../promtool check config --syntax-only $$file; done diff --git a/documentation/examples/custom-sd/adapter/adapter.go b/documentation/examples/custom-sd/adapter/adapter.go index b0ed5ab9aa..57c32ce492 100644 --- a/documentation/examples/custom-sd/adapter/adapter.go +++ b/documentation/examples/custom-sd/adapter/adapter.go @@ -155,6 +155,7 @@ func (a *Adapter) runCustomSD(ctx context.Context) { // Run starts a Discovery Manager and the custom service discovery implementation. func (a *Adapter) Run() { + //nolint:errcheck go a.manager.Run() a.manager.StartCustomProvider(a.ctx, a.name, a.disc) go a.runCustomSD(a.ctx) diff --git a/documentation/examples/prometheus-hetzner.yml b/documentation/examples/prometheus-hetzner.yml index ccc1ffc287..1638efab69 100644 --- a/documentation/examples/prometheus-hetzner.yml +++ b/documentation/examples/prometheus-hetzner.yml @@ -13,7 +13,7 @@ scrape_configs: hetzner_sd_configs: - authorization: credentials: "" - platform: "hcloud" + role: "hcloud" relabel_configs: # Use the public IPv4 and port 9100 to scrape the target. - source_labels: [__meta_hetzner_public_ipv4] @@ -26,7 +26,7 @@ scrape_configs: hetzner_sd_configs: - authorization: credentials: "" - platform: "hcloud" + role: "hcloud" relabel_configs: # Use the private IPv4 within the Hetzner Cloud Network and port 9100 to scrape the target. - source_labels: [__meta_hetzner_hcloud_private_ipv4_mynet] @@ -40,7 +40,7 @@ scrape_configs: - basic_auth: username: "" password: "" - platform: "robot" + role: "robot" relabel_configs: # Use the public IPv4 and port 9100 to scrape the target. - source_labels: [__meta_hetzner_public_ipv4] diff --git a/documentation/examples/prometheus-vultr.yml b/documentation/examples/prometheus-vultr.yml index 5370c36317..1b2e8ff8c8 100644 --- a/documentation/examples/prometheus-vultr.yml +++ b/documentation/examples/prometheus-vultr.yml @@ -11,7 +11,7 @@ scrape_configs: - job_name: "node" vultr_sd_configs: - authorization: - credentials: "" + credentials: "" relabel_configs: # Only scrape targets that have a tag 'monitoring'. - source_labels: [__meta_vultr_instance_tags]