Browse Source

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 <dgl@dgl.cx>

* No need to import Makefile.common, it just complicates things

Signed-off-by: David Leadbeater <dgl@dgl.cx>
pull/10756/head
David Leadbeater 3 years ago committed by GitHub
parent
commit
fba3e847dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .circleci/config.yml
  2. 20
      documentation/examples/Makefile
  3. 1
      documentation/examples/custom-sd/adapter/adapter.go
  4. 6
      documentation/examples/prometheus-hetzner.yml
  5. 2
      documentation/examples/prometheus-vultr.yml

1
.circleci/config.yml

@ -38,6 +38,7 @@ jobs:
GO111MODULE: "on" GO111MODULE: "on"
- run: go test ./tsdb/ -test.tsdb-isolation=false - run: go test ./tsdb/ -test.tsdb-isolation=false
- run: make -C documentation/examples/remote_storage - run: make -C documentation/examples/remote_storage
- run: make -C documentation/examples
- prometheus/check_proto: - prometheus/check_proto:
version: "3.15.8" version: "3.15.8"
- prometheus/store_artifact: - prometheus/store_artifact:

20
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

1
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. // Run starts a Discovery Manager and the custom service discovery implementation.
func (a *Adapter) Run() { func (a *Adapter) Run() {
//nolint:errcheck
go a.manager.Run() go a.manager.Run()
a.manager.StartCustomProvider(a.ctx, a.name, a.disc) a.manager.StartCustomProvider(a.ctx, a.name, a.disc)
go a.runCustomSD(a.ctx) go a.runCustomSD(a.ctx)

6
documentation/examples/prometheus-hetzner.yml

@ -13,7 +13,7 @@ scrape_configs:
hetzner_sd_configs: hetzner_sd_configs:
- authorization: - authorization:
credentials: "<replace with a Hetzner Cloud API Token>" credentials: "<replace with a Hetzner Cloud API Token>"
platform: "hcloud" role: "hcloud"
relabel_configs: relabel_configs:
# Use the public IPv4 and port 9100 to scrape the target. # Use the public IPv4 and port 9100 to scrape the target.
- source_labels: [__meta_hetzner_public_ipv4] - source_labels: [__meta_hetzner_public_ipv4]
@ -26,7 +26,7 @@ scrape_configs:
hetzner_sd_configs: hetzner_sd_configs:
- authorization: - authorization:
credentials: "<replace with a Hetzner Cloud API Token>" credentials: "<replace with a Hetzner Cloud API Token>"
platform: "hcloud" role: "hcloud"
relabel_configs: relabel_configs:
# Use the private IPv4 within the Hetzner Cloud Network and port 9100 to scrape the target. # Use the private IPv4 within the Hetzner Cloud Network and port 9100 to scrape the target.
- source_labels: [__meta_hetzner_hcloud_private_ipv4_mynet] - source_labels: [__meta_hetzner_hcloud_private_ipv4_mynet]
@ -40,7 +40,7 @@ scrape_configs:
- basic_auth: - basic_auth:
username: "<replace with a Hetzner Robot API username>" username: "<replace with a Hetzner Robot API username>"
password: "<replace with a Hetzner Robot API password>" password: "<replace with a Hetzner Robot API password>"
platform: "robot" role: "robot"
relabel_configs: relabel_configs:
# Use the public IPv4 and port 9100 to scrape the target. # Use the public IPv4 and port 9100 to scrape the target.
- source_labels: [__meta_hetzner_public_ipv4] - source_labels: [__meta_hetzner_public_ipv4]

2
documentation/examples/prometheus-vultr.yml

@ -11,7 +11,7 @@ scrape_configs:
- job_name: "node" - job_name: "node"
vultr_sd_configs: vultr_sd_configs:
- authorization: - authorization:
credentials: "<replace with a Personal Access Token>" credentials: "<replace with a Personal Access Token>"
relabel_configs: relabel_configs:
# Only scrape targets that have a tag 'monitoring'. # Only scrape targets that have a tag 'monitoring'.
- source_labels: [__meta_vultr_instance_tags] - source_labels: [__meta_vultr_instance_tags]

Loading…
Cancel
Save