diff --git a/.dockerignore b/.dockerignore index 0967099155..507a7203d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,3 +8,6 @@ data/ !.build/linux-ppc64le/ !.build/linux-riscv64/ !.build/linux-s390x/ + +/vendor + diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 0000000000..87dd89ddeb --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,3 @@ +.git +.gitignore +#!include:.gitignore diff --git a/.github/workflows/automerge-dependabot.yml b/.github/workflows/automerge-dependabot.yml deleted file mode 100644 index 8b07f4df95..0000000000 --- a/.github/workflows/automerge-dependabot.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Dependabot auto-merge -on: pull_request - -concurrency: - group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - dependabot: - permissions: - contents: write - pull-requests: write - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository_owner == 'prometheus' }} - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Enable auto-merge for Dependabot PRs - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}} - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/buf-lint.yml b/.github/workflows/buf-lint.yml deleted file mode 100644 index d2c78cd6de..0000000000 --- a/.github/workflows/buf-lint.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: buf.build -on: - pull_request: - paths: - - ".github/workflows/buf-lint.yml" - - "**.proto" -permissions: - contents: read - -jobs: - buf: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: bufbuild/buf-setup-action@a47c93e0b1648d5651a065437926377d060baa99 # v1.50.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - uses: bufbuild/buf-lint-action@06f9dd823d873146471cfaaf108a993fe00e5325 # v1.1.1 - with: - input: 'prompb' - - uses: bufbuild/buf-breaking-action@c57b3d842a5c3f3b454756ef65305a50a587c5ba # v1.1.4 - with: - input: 'prompb' - against: 'https://github.com/prometheus/prometheus.git#branch=main,ref=HEAD,subdir=prompb' diff --git a/.github/workflows/buf.yml b/.github/workflows/buf.yml deleted file mode 100644 index fcfdc43c6d..0000000000 --- a/.github/workflows/buf.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: buf.build -on: - push: - branches: - - main -permissions: - contents: read - -jobs: - buf: - name: lint and publish - runs-on: ubuntu-latest - if: github.repository_owner == 'prometheus' - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: bufbuild/buf-setup-action@a47c93e0b1648d5651a065437926377d060baa99 # v1.50.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - uses: bufbuild/buf-lint-action@06f9dd823d873146471cfaaf108a993fe00e5325 # v1.1.1 - with: - input: 'prompb' - - uses: bufbuild/buf-breaking-action@c57b3d842a5c3f3b454756ef65305a50a587c5ba # v1.1.4 - with: - input: 'prompb' - against: 'https://github.com/prometheus/prometheus.git#branch=main,ref=HEAD~1,subdir=prompb' - - uses: bufbuild/buf-push-action@a654ff18effe4641ebea4a4ce242c49800728459 # v1.2.0 - with: - input: 'prompb' - buf_token: ${{ secrets.BUF_TOKEN }} diff --git a/.github/workflows/check_release_notes.yml b/.github/workflows/check_release_notes.yml deleted file mode 100644 index c2bd1b1d64..0000000000 --- a/.github/workflows/check_release_notes.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: 'Check release notes' -on: - pull_request: - branches: [main, 'release-*'] - types: - - opened - - reopened - - edited - - synchronize -permissions: - contents: read - pull-requests: read - -jobs: - check_release_notes: - name: check - runs-on: ubuntu-latest - # Don't run this workflow on forks. - # Don't run it on dependabot PRs either as humans would take control in case a bump introduces a breaking change. - if: (github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community') && github.event.pull_request.user.login != 'dependabot[bot]' - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - env: - PR_DESCRIPTION: ${{ github.event.pull_request.body }} - run: | - echo "$PR_DESCRIPTION" | ./scripts/check_release_notes.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8ec474e182..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,418 +0,0 @@ ---- -name: CI -on: - pull_request: - push: - branches: [main, 'release-*'] - tags: ['v*'] - -permissions: - contents: read - -jobs: - test_go: - name: Go tests - runs-on: ubuntu-latest - container: - # Whenever the Go version is updated here, .promu.yml - # should also be updated. - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - with: - enable_npm: true - - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 - - run: go test ./tsdb/ -test.tsdb-isolation=false - - run: make -C documentation/examples/remote_storage - - run: make -C documentation/examples - - test_go_more: - name: More Go tests - runs-on: ubuntu-latest - container: - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - - run: go test --tags=dedupelabels ./... - - run: go test --tags=slicelabels -race ./cmd/prometheus ./model/textparse ./prompb/... - - run: go test --tags=forcedirectio -race ./tsdb/ - - run: make protoc - - run: make proto - - run: git diff --exit-code - - test_go_386: - name: Go tests for 32-bit x86 - runs-on: ubuntu-latest - container: - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - # NOTE(bwplotka): We limit concurrency to avoid issues around too many concurrent mmaps - # caused by parallel tests. See context: https://github.com/prometheus/prometheus/pull/18709 - # Alternatively we could adjust each relevant test to have 386 aware parallelization setting. - - run: GOARCH=386 go test -parallel=1 ./... - - test_version_upgrade: - name: Go tests for Prometheus upgrades and downgrades - runs-on: ubuntu-latest - container: - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - - run: go test -v --race ./cmd/prometheus/ --test.version-upgrade=true -run TestVersionUpgrade - - test_go_oldest: - name: Go tests with previous Go version - runs-on: ubuntu-latest - env: - # Enforce the Go version. - GOTOOLCHAIN: local - container: - # The go version in this image should be N-1 wrt test_go. - image: quay.io/prometheus/golang-builder:1.25-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - run: make build - # Don't run NPM build; don't run race-detector. - - run: make test GO_ONLY=1 test-flags="" - - test_ui: - name: UI tests - runs-on: ubuntu-latest - # Whenever the Go version is updated here, .promu.yml - # should also be updated. - container: - image: quay.io/prometheus/golang-builder:1.26-base - - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - with: - enable_go: false - enable_npm: true - - run: make assets-tarball - - run: make ui-lint - - run: make ui-test - - uses: prometheus/promci-artifacts/save@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 - with: - directory: .tarballs - - test_windows: - name: Go tests on Windows - runs-on: windows-latest - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 - with: - go-version: 1.26.x - - run: | - $TestTargets = go list ./... | Where-Object { $_ -NotMatch "(github.com/prometheus/prometheus/config|github.com/prometheus/prometheus/web)"} - go test $TestTargets -vet=off -v - shell: powershell - - test_mixins: - name: Mixins tests - runs-on: ubuntu-latest - # Whenever the Go version is updated here, .promu.yml - # should also be updated. - container: - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - run: go install ./cmd/promtool/. - - run: go install github.com/google/go-jsonnet/cmd/jsonnet@latest - - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest - - run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest - - run: make -C documentation/prometheus-mixin clean - - run: make -C documentation/prometheus-mixin jb_install - - run: make -C documentation/prometheus-mixin - - run: git diff --exit-code - - test-compliance: - name: Compliance testing - runs-on: ubuntu-latest - container: - # Whenever the Go version is updated here, .promu.yml - # should also be updated. - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - with: - enable_npm: false - # NOTE: Those tests are based on https://github.com/prometheus/compliance and - # are executed against the ./cmd/prometheus main package. - - run: go test -v --tags=compliance ./compliance/... - - build: - name: Build Prometheus for common architectures - runs-on: ubuntu-latest - # Reuse the web UI built and tested by test_ui instead of rebuilding it in - # every crossbuild container. - needs: [test_ui] - if: | - !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - && - !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - && - !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) - && - !(github.event_name == 'push' && github.event.ref == 'refs/heads/main') - strategy: - matrix: - thread: [ 0, 1, 2 ] - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 - - name: Extract pre-built UI assets - run: | - mkdir -p .prebuilt-ui - tar -xzvf .tarballs/prometheus-web-ui-*.tar.gz -C .prebuilt-ui - - uses: prometheus/promci/build@c7d527128ffb38ad3d7934795da35b252c7d51dd # v0.8.3 - with: - checkout: false - # Feed the restored UI assets into the crossbuild containers so make - # skips the UI build (see PREBUILT_ASSETS_STATIC_DIR in the Makefile). - promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386 --env PREBUILT_ASSETS_STATIC_DIR=.prebuilt-ui/static" - parallelism: 3 - thread: ${{ matrix.thread }} - build_all: - name: Build Prometheus for all architectures - runs-on: ubuntu-latest - # Reuse the web UI built and tested by test_ui instead of rebuilding it in - # every crossbuild container. - needs: [test_ui] - if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - || - (github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-')) - || - (github.event_name == 'push' && github.event.ref == 'refs/heads/main') - strategy: - matrix: - thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] - - # Whenever the Go version is updated here, .promu.yml - # should also be updated. - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-artifacts/restore@f9a587dbc0b2c78a0c54f8ad1cde71ea29a4b76f # v0.1.0 - - name: Extract pre-built UI assets - run: | - mkdir -p .prebuilt-ui - tar -xzvf .tarballs/prometheus-web-ui-*.tar.gz -C .prebuilt-ui - - uses: prometheus/promci/build@c7d527128ffb38ad3d7934795da35b252c7d51dd # v0.8.3 - with: - checkout: false - parallelism: 12 - thread: ${{ matrix.thread }} - # Feed the restored UI assets into the crossbuild containers so make - # skips the UI build (see PREBUILT_ASSETS_STATIC_DIR in the Makefile). - promu_opts: --env PREBUILT_ASSETS_STATIC_DIR=.prebuilt-ui/static - build_all_status: - # This status check aggregates the individual matrix jobs of the "Build - # Prometheus for all architectures" step into a final status. Fails if a - # single matrix job fails, succeeds if all matrix jobs succeed. - # See https://github.com/orgs/community/discussions/4324 for why this is - # needed - name: Report status of build Prometheus for all architectures - runs-on: ubuntu-latest - needs: [build_all] - # The run condition needs to include always(). Otherwise actions - # behave unexpected: - # only "needs" will make the Status Report be skipped if one of the builds fails https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-jobs-in-a-workflow#defining-prerequisite-jobs - # And skipped is treated as success https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborat[…]n-repositories-with-code-quality-features/about-status-checks - # Adding always ensures that the status check is run independently of the - # results of Build All - if: always() && github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-') - steps: - - name: Successful build - if: ${{ !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled')) }} - run: exit 0 - - name: Failing or cancelled build - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - run: exit 1 - check_generated_parser: - # Checks generated parser and UI functions list. Not renaming as it is a required check. - name: Check generated parser - runs-on: ubuntu-latest - container: - image: quay.io/prometheus/golang-builder:1.26-base - steps: - - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 - with: - enable_npm: true - - run: make install-goyacc check-generated-parser - - run: make check-generated-promql-functions - golangci: - name: golangci-lint - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - name: Install Go - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 - with: - go-version: 1.26.x - - name: Install snmp_exporter/generator dependencies - run: sudo apt-get update && sudo apt-get -y install libsnmp-dev - if: github.repository == 'prometheus/snmp_exporter' - - name: Get golangci-lint version - id: golangci-lint-version - run: echo "version=$(make print-golangci-lint-version)" >> $GITHUB_OUTPUT - - name: Lint - uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 - with: - args: --verbose - version: ${{ steps.golangci-lint-version.outputs.version }} - - name: Lint with slicelabels - uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 - with: - args: --verbose --build-tags=slicelabels - version: ${{ steps.golangci-lint-version.outputs.version }} - - name: Lint with dedupelabels - uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 - with: - args: --verbose --build-tags=dedupelabels - version: ${{ steps.golangci-lint-version.outputs.version }} - - name: Lint in compliance - uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 - with: - args: --verbose - working-directory: compliance - version: ${{ steps.golangci-lint-version.outputs.version }} - - name: Lint in documentation/examples/remote_storage - uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1 - with: - args: --verbose - working-directory: documentation/examples/remote_storage - version: ${{ steps.golangci-lint-version.outputs.version }} - fuzzing: - uses: ./.github/workflows/fuzzing.yml - if: github.event_name == 'pull_request' - codeql: - uses: ./.github/workflows/codeql-analysis.yml - permissions: - contents: read - security-events: write - - publish_main: - name: Publish main branch artifacts - runs-on: ubuntu-latest - permissions: - packages: write - needs: [test_ui, test_go, test_go_more, test_go_oldest, test_windows, golangci, codeql, build_all] - if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' - steps: - - uses: prometheus/promci/publish_main@c7d527128ffb38ad3d7934795da35b252c7d51dd # v0.8.3 - with: - docker_hub_login: ${{ secrets.docker_hub_login }} - docker_hub_password: ${{ secrets.docker_hub_password }} - ghcr_io_password: ${{ github.token }} - quay_io_login: ${{ secrets.quay_io_login }} - quay_io_password: ${{ secrets.quay_io_password }} - publish_release: - name: Publish release artefacts - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - needs: [test_ui, test_go, test_go_more, test_go_oldest, test_windows, golangci, codeql, build_all] - if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - steps: - - uses: prometheus/promci/publish_release@c7d527128ffb38ad3d7934795da35b252c7d51dd # v0.8.3 - with: - docker_hub_login: ${{ secrets.docker_hub_login }} - docker_hub_password: ${{ secrets.docker_hub_password }} - ghcr_io_password: ${{ github.token }} - quay_io_login: ${{ secrets.quay_io_login }} - quay_io_password: ${{ secrets.quay_io_password }} - github_token: ${{ github.token }} - publish_ui_release: - name: Publish UI on npm Registry - runs-on: ubuntu-latest - needs: [test_ui, codeql] - permissions: - contents: read - # Required for npm trusted publishing via OIDC. - id-token: write - steps: - - name: Checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - name: Install nodejs - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version-file: "web/ui/.nvmrc" - registry-url: "https://registry.npmjs.org" - - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 - with: - version: 11 - - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: ~/.local/share/pnpm/store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - name: Check libraries version - if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - run: ./scripts/ui_release.sh --check-package "$(./scripts/get_module_version.sh ${GH_REF_NAME})" - env: - GH_REF_NAME: ${{ github.ref_name }} - - name: build - run: make assets - - name: Copy files before publishing libs - run: ./scripts/ui_release.sh --copy - - name: Publish dry-run libraries - if: | - !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - && - !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - run: ./scripts/ui_release.sh --publish dry-run - - name: Publish libraries - if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v3.')) - run: ./scripts/ui_release.sh --publish diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 51c08d879e..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: "CodeQL" - -on: - workflow_call: - schedule: - - cron: "26 14 * * 1" - -permissions: {} - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ["javascript"] - - steps: - - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 diff --git a/.github/workflows/container_description.yml b/.github/workflows/container_description.yml deleted file mode 100644 index 3bb36ccf43..0000000000 --- a/.github/workflows/container_description.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -name: Push README to Docker Hub -on: - push: - paths: - - "README.md" - - "README-containers.md" - - ".github/workflows/container_description.yml" - branches: [ main, master ] - -permissions: - contents: read - -jobs: - PushDockerHubReadme: - runs-on: ubuntu-latest - name: Push README to Docker Hub - if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. - steps: - - name: git checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - name: Set docker hub repo name - run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV - - name: Push README to Dockerhub - uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 - env: - DOCKER_USER: ${{ secrets.DOCKER_HUB_LOGIN }} - DOCKER_PASS: ${{ secrets.DOCKER_HUB_PASSWORD }} - with: - destination_container_repo: ${{ env.DOCKER_REPO_NAME }} - provider: dockerhub - short_description: ${{ env.DOCKER_REPO_NAME }} - # Empty string results in README-containers.md being pushed if it - # exists. Otherwise, README.md is pushed. - readme_file: '' - - PushQuayIoReadme: - runs-on: ubuntu-latest - name: Push README to quay.io - if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. - steps: - - name: git checkout - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - name: Set quay.io org name - run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV - - name: Set quay.io repo name - run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV - - name: Push README to quay.io - uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1 - env: - DOCKER_APIKEY: ${{ secrets.QUAY_IO_API_TOKEN }} - with: - destination_container_repo: ${{ env.DOCKER_REPO_NAME }} - provider: quay - # Empty string results in README-containers.md being pushed if it - # exists. Otherwise, README.md is pushed. - readme_file: '' diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml deleted file mode 100644 index 856e01e35c..0000000000 --- a/.github/workflows/fuzzing.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: fuzzing -on: - workflow_call: -permissions: - contents: read - -jobs: - fuzzing: - name: Run Go Fuzz Tests - runs-on: ubuntu-latest - strategy: - matrix: - fuzz_test: [[FuzzParseMetricText, FuzzParseOpenMetric], [FuzzParseMetricSelector, FuzzParseExpr], [FuzzXORChunk, FuzzXOR2Chunk], [FuzzParseProtobuf]] - steps: - - name: Checkout repository - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - name: Install Go - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 - with: - go-version: 1.26.x - - name: Run Fuzzing - run: | - for fuzz_test in ${{ join(matrix.fuzz_test, ' ') }}; do - go test -fuzz="${fuzz_test}$" -fuzztime=4m ./util/fuzzing - done - id: fuzz - - name: Upload Crash Artifacts - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - if: failure() - with: - name: fuzz-artifacts-${{ join(matrix.fuzz_test, '-') }} - path: util/fuzzing/testdata/fuzz/ - fuzzing_status: - # This status check aggregates the individual matrix jobs of the fuzzing - # step into a final status. Fails if a single matrix job fails, succeeds if - # all matrix jobs succeed. - name: Fuzzing - runs-on: ubuntu-latest - needs: [fuzzing] - if: always() - steps: - - name: Successful fuzzing - if: ${{ !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled')) }} - run: exit 0 - - name: Failing or cancelled fuzzing - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - run: exit 1 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml deleted file mode 100644 index 621476dec4..0000000000 --- a/.github/workflows/govulncheck.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: govulncheck -on: - pull_request: - paths: - - VERSION - - .github/workflows/govulncheck.yml - push: - branches: - - main - - master - schedule: - - cron: '33 2 * * *' - -permissions: - contents: read - -jobs: - govulncheck: - runs-on: ubuntu-latest - name: Run govulncheck - steps: - - name: Install snmp_exporter/generator dependencies - id: snmp-deps - run: sudo apt-get update && sudo apt-get -y install libsnmp-dev - if: github.repository == 'prometheus/snmp_exporter' - - id: govulncheck - uses: golang/govulncheck-action@3fa7bd9cee2cfdf3499a8803b226e43de7b7cdb4 # master - env: - GOOS: ${{ contains(github.repository, 'windows_exporter') && 'windows' || '' }} diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml deleted file mode 100644 index de63095305..0000000000 --- a/.github/workflows/lock.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: 'Lock Threads' - -on: - schedule: - - cron: '13 23 * * *' - workflow_dispatch: - -permissions: - issues: write - -concurrency: - group: lock - -jobs: - action: - runs-on: ubuntu-latest - if: github.repository_owner == 'prometheus' - steps: - - uses: dessant/lock-threads@89ae32b08ed1a541efecbab17912962a5e38981c # v6.0.2 - with: - process-only: 'issues' - issue-inactive-days: '180' - github-token: ${{ secrets.PROMBOT_LOCKTHREADS_TOKEN }} diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml new file mode 100644 index 0000000000..be5722dfdd --- /dev/null +++ b/.github/workflows/presubmit.yml @@ -0,0 +1,79 @@ +# Copyright 2025 Google LLC +# +# 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 +# +# https://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. +name: Presubmit +on: + push: + +permissions: + contents: read + +jobs: + go: + name: Go & npm tests + runs-on: ubuntu-latest + container: + image: quay.io/prometheus/golang-builder:1.26-base + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + - uses: prometheus/promci-setup@3e5cd31b34b8ae19efa8f071c5e3cdb44884a7f8 # v0.2.1 + with: + enable_npm: true + - run: make install-goyacc build test + build-image-amd64: + name: Ensure Google image builds (amd64) + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 + - name: Ensure forked image is buildable + run: | + # Our dockerfile expects npm vendoring, yet this is done during the mirror stage. + # Do it on demand here, similar to how it will be added in our mirror job. + GOWORK=off go mod vendor + find . -name "package.json" -not -path "*/node_modules/*" -execdir npm install \; + + docker run --rm --privileged multiarch/qemu-user-static --reset --credential yes --persistent yes + docker buildx create --name multi-arch-builder --use + docker buildx build -f Dockerfile.google -t gmp-prometheus:amd64 . --platform linux/amd64 --target=app --load + - name: Save Docker image as a tar archive + run: docker save gmp-prometheus:amd64 -o image.tar + - name: Upload Docker image artifact for the next tests + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: gmp-prometheus-amd64 + path: image.tar + test-export-gcm: + name: GCM e2e tests + runs-on: ubuntu-latest + # This job now depends on build-image-amd64 and will run only after it succeeds. + needs: build-image-amd64 + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - name: Download Docker image artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: gmp-prometheus-amd64 + - name: Load Docker image + run: docker load -i image.tar + - name: Run export GCM tests + env: + GCM_SECRET: ${{ secrets.GCM_SECRET }} + GMP_PROMETHEUS_IMAGE: "gmp-prometheus:amd64" + run: make -C ./google/internal/promqle2etest test + diff --git a/.github/workflows/prombench.yml b/.github/workflows/prombench.yml deleted file mode 100644 index 34bea41d54..0000000000 --- a/.github/workflows/prombench.yml +++ /dev/null @@ -1,136 +0,0 @@ -on: - repository_dispatch: - types: [prombench_start, prombench_restart, prombench_stop] -name: Prombench Workflow -permissions: - contents: read -env: - AUTH_FILE: ${{ secrets.TEST_INFRA_PROVIDER_AUTH }} - CLUSTER_NAME: test-infra - DOMAIN_NAME: prombench.prometheus.io - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_ORG: prometheus - GITHUB_REPO: prometheus - GITHUB_STATUS_TARGET_URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} - LAST_COMMIT_SHA: ${{ github.event.client_payload.LAST_COMMIT_SHA }} - GKE_PROJECT_ID: macro-mile-203600 - PR_NUMBER: ${{ github.event.client_payload.PR_NUMBER }} - PROVIDER: gke - RELEASE: ${{ github.event.client_payload.RELEASE }} - BENCHMARK_VERSION: ${{ github.event.client_payload.BENCHMARK_VERSION }} - BENCHMARK_DIRECTORY: ${{ github.event.client_payload.BENCHMARK_DIRECTORY }} - ZONE: europe-west3-a -jobs: - benchmark_start: - name: Benchmark Start - if: github.event.action == 'prombench_start' - permissions: - statuses: write - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make deploy to start test - id: make_deploy - uses: docker://prominfra/prombench:master - with: - args: >- - make deploy; - until make all_nodes_running; do echo "waiting for nodepools to be created"; sleep 10; done; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-start", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - benchmark_cancel: - name: Benchmark Cancel - if: github.event.action == 'prombench_stop' - permissions: - statuses: write - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make clean to stop test - id: make_clean - uses: docker://prominfra/prombench:master - with: - args: >- - make clean; - until make all_nodes_deleted; do echo "waiting for nodepools to be deleted"; sleep 10; done; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-cancel", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - benchmark_restart: - name: Benchmark Restart - if: github.event.action == 'prombench_restart' - permissions: - statuses: write - runs-on: ubuntu-latest - steps: - - name: Update status to pending - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"pending", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Run make clean then make deploy to restart test - id: make_restart - uses: docker://prominfra/prombench:master - with: - args: >- - make clean; - until make all_nodes_deleted; do echo "waiting for nodepools to be deleted"; sleep 10; done; - make deploy; - until make all_nodes_running; do echo "waiting for nodepools to be created"; sleep 10; done; - - name: Update status to failure - if: failure() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"failure", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" - - name: Update status to success - if: success() - run: >- - curl -i -X POST - -H "Authorization: Bearer $GITHUB_TOKEN" - -H "Content-Type: application/json" - --data '{"state":"success", "context": "prombench-status-update-restart", "target_url": "'$GITHUB_STATUS_TARGET_URL'"}' - "https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$LAST_COMMIT_SHA" diff --git a/.github/workflows/repo_sync.yml b/.github/workflows/repo_sync.yml deleted file mode 100644 index 9395f2d036..0000000000 --- a/.github/workflows/repo_sync.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Sync repo files -on: - schedule: - - cron: '44 17 * * *' - workflow_dispatch: {} -permissions: - contents: read - -jobs: - repo_sync: - runs-on: ubuntu-latest - if: github.repository_owner == 'prometheus' - container: - image: quay.io/prometheus/golang-builder - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - run: ./scripts/sync_repo_files.sh - env: - GITHUB_TOKEN: ${{ secrets.PROMBOT_REPOSYNC_TOKEN }} - GITHUB_TOKEN_PROMETHEUS: ${{ secrets.PROMBOT_REPOSYNC_TOKEN_PROMETHEUS }} - GITHUB_TOKEN_PROMETHEUS_COMMUNITY: ${{ secrets.PROMBOT_REPOSYNC_TOKEN_PROMETHEUS_COMMUNITY }} diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml deleted file mode 100644 index bfaad919c9..0000000000 --- a/.github/workflows/scorecards.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2022 Google LLC - -name: Scorecards supply-chain security -on: - pull_request: - push: - branches: [ "main" ] - -# Declare default permissions as read only. -permissions: read-all - -jobs: - analysis: - name: Scorecards analysis - runs-on: ubuntu-latest - permissions: - # Needed to upload the results to code-scanning dashboard. - security-events: write - # Used to receive a badge. - id-token: write - - steps: - - name: "Checkout code" - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - with: - persist-credentials: false - - - name: "Run analysis" - uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # tag=v2.4.3 - with: - results_file: results.sarif - results_format: sarif - # Publish the results for public repositories to enable scorecard badges. For more details, see - # https://github.com/ossf/scorecard-action#publishing-results. - publish_results: ${{ github.event_name != 'pull_request' }} - - # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF - # format to the repository Actions tab. - - name: "Upload artifact" - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: SARIF file - path: results.sarif - retention-days: 5 - - # Upload the results to GitHub's code scanning dashboard. - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2 - with: - sarif_file: results.sarif diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 74d037f8f1..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Stale Check -on: - workflow_dispatch: {} - schedule: - - cron: '16 22 * * *' -permissions: - issues: write - pull-requests: write -jobs: - stale: - if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks. - runs-on: ubuntu-latest - steps: - - uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - # opt out of defaults to avoid marking issues as stale and closing them - # https://github.com/actions/stale#days-before-close - # https://github.com/actions/stale#days-before-stale - days-before-stale: -1 - days-before-close: -1 - # Setting it to empty string to skip comments. - # https://github.com/actions/stale#stale-pr-message - # https://github.com/actions/stale#stale-issue-message - stale-pr-message: '' - stale-issue-message: '' - operations-per-run: 30 - # override days-before-stale, for only marking the pull requests as stale - days-before-pr-stale: 60 - stale-pr-label: stale - exempt-pr-labels: keepalive diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cfb346e4d0..37ae0a4471 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,101 +1,33 @@ -# Contributing +# How to Contribute -Prometheus uses GitHub to manage reviews of pull requests. +We'd love to accept your patches and contributions to this project. -* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute) +## Before you begin -* If you have a trivial fix or improvement, go ahead and create a pull request, - addressing (with `@...`) a suitable maintainer of this repository (see - [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request. +### Sign our Contributor License Agreement -* If you plan to do something more involved, first discuss your ideas - on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers). - This will avoid unnecessary work and surely give you and us a good deal - of inspiration. Also please see our [non-goals issue](https://github.com/prometheus/docs/issues/149) on areas that the Prometheus community doesn't plan to work on. +Contributions to this project must be accompanied by a +[Contributor License Agreement](https://cla.developers.google.com/about) (CLA). +You (or your employer) retain the copyright to your contribution; this simply +gives us permission to use and redistribute your contributions as part of the +project. -* Relevant coding style guidelines are the [Go Code Review - Comments](https://go.dev/wiki/CodeReviewComments) - and the _Formatting and style_ section of Peter Bourgon's [Go: Best - Practices for Production - Environments](https://peter.bourgon.org/go-in-production/#formatting-and-style). +If you or your current employer have already signed the Google CLA (even if it +was for a different project), you probably don't need to do it again. -* Be sure to sign off on the [DCO](https://github.com/probot/dco#how-it-works). +Visit to see your current agreements or to +sign a new one. -## Steps to Contribute +### Review our Community Guidelines -Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue. +This project follows +[Google's Open Source Community Guidelines](https://opensource.google/conduct/). -Please check the [`low-hanging-fruit`](https://github.com/prometheus/prometheus/issues?q=is%3Aissue+is%3Aopen+label%3A%22low+hanging+fruit%22) label to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the maintainers will clarify it. For a quicker response, contact us over [IRC](https://prometheus.io/community). +## Contribution process -You can [spin up a prebuilt dev environment](https://gitpod.io/#https://github.com/prometheus/prometheus) using Gitpod.io. +### Code Reviews -For complete instructions on how to compile see: [Building From Source](https://github.com/prometheus/prometheus#building-from-source) - -For quickly compiling and testing your changes do: - -```bash -# For building. -go build ./cmd/prometheus/ -./prometheus - -# For testing. -make test # Make sure all the tests pass before you commit and push :) -``` - -To run a collection of Go linters through [`golangci-lint`](https://github.com/golangci/golangci-lint), do: -```bash -make lint -``` - -If it reports an issue and you think that the warning needs to be disregarded or is a false-positive, you can add a special comment `//nolint:linter1[,linter2,...]` before the offending line. Use this sparingly though, fixing the code to comply with the linter's recommendation is in general the preferred course of action. See [this section of the golangci-lint documentation](https://golangci-lint.run/usage/false-positives/#nolint-directive) for more information. - -All our issues are regularly tagged so that you can also filter down the issues involving the components you want to work on. For our labeling policy refer [the wiki page](https://github.com/prometheus/prometheus/wiki/Label-Names-and-Descriptions). - -## Pull Request Checklist - -* Branch from the main branch and, if needed, rebase to the current main branch before submitting your pull request. If it doesn't merge cleanly with main you may be asked to rebase your changes. - -* Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). - -* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review on the IRC channel [#prometheus-dev](https://web.libera.chat/?channels=#prometheus-dev) on irc.libera.chat (for the easiest start, [join via Element](https://app.element.io/#/room/#prometheus-dev:matrix.org)). - -* Add tests relevant to the fixed bug or new feature. - -## Dependency management - -The Prometheus project uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. - -To add or update a new dependency, use the `go get` command: - -```bash -# Pick the latest tagged release. -go get example.com/some/module/pkg@latest - -# Pick a specific version. -go get example.com/some/module/pkg@vX.Y.Z -``` - -Tidy up the `go.mod` and `go.sum` files: - -```bash -go mod tidy -``` - -You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request. - -## Working with the PromQL parser - -The PromQL parser grammar is located in `promql/parser/generated_parser.y` and it can be built using `make parser`. -The parser is built using [goyacc](https://pkg.go.dev/golang.org/x/tools/cmd/goyacc) - -If doing some sort of debugging, then it is possible to add some verbose output. After generating the parser, then you -can modify the `./promql/parser/generated_parser.y.go` manually. - -```golang -// As of writing this was somewhere around line 600. -var ( - yyDebug = 0 // This can be a number 0 -> 5. - yyErrorVerbose = false // This can be set to true. -) - -``` +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. diff --git a/Dockerfile.google b/Dockerfile.google new file mode 100644 index 0000000000..29fe2079b6 --- /dev/null +++ b/Dockerfile.google @@ -0,0 +1,124 @@ +# This dockerfile is multi target. Use DOCKER_BUILDKIT=1 when building and reference the target: +# --target=vendor with -o to build image with the generated dependencies to copy and vendor on demand. +# --target=app to build actual application image. + +# For the lack of the other official Google nodejs image, we use serverless project +# images to build the Prometheus frontent (https://cloud.google.com/docs/buildpacks/base-images). +ARG IMAGE_BUILD_NODEJS=us-central1-docker.pkg.dev/serverless-runtimes/google-22/runtimes/nodejs22:latest@sha256:9e88442205b4c956ca4996c2be626db6ef412043182cdd620e741d0d5e14b6a6 +ARG IMAGE_BUILD_GO=google-go.pkg.dev/golang:1.26.4@sha256:3444149d0a7e3f7cfb9c2db65f0f75676fe6ad04de3ce72674efb120c08dd1c1 +ARG IMAGE_BASE_DEBUG=gcr.io/distroless/base-nossl-debian12:debug@sha256:2b89aea887933b8595f62c3d7e05a2718a0594e21e506952ce55b68b537f4fb6 +ARG IMAGE_BASE=gke.gcr.io/gke-distroless/libc:gke_distroless_20260601.00_p0@sha256:1b74f92a381c5269d5018b08ce0464cfcb310b6b9b6d98767ba3300838483fc4 + +FROM ${IMAGE_BUILD_GO} AS gobase +WORKDIR /workspace +# Verify early if we have all we need. +RUN go version + +FROM ${IMAGE_BUILD_NODEJS} AS nodebase +WORKDIR /workspace +# Changed to root,as normally it's underprivileged www-data user. +# For building stages it's fine to do it as root and have less complex scripts. +USER root +# Go, make, git, bzip2 are needed in Prometheus vendor and build steps, take Go +# from the gobase, rest from apt. +COPY --from=gobase /usr/local/go /usr/local/ +ENV PATH="/usr/local/go/bin:${PATH}" +ENV UV_USE_IO_URING=0 +ENV UV_THREADPOOL_SIZE=1 +RUN apt-get update && apt-get -y install bzip2 make git +RUN corepack enable pnpm +RUN pnpm config set child-concurrency 1 +# Verify early if we have all we need. +RUN npm version +RUN pnpm --version +RUN make -v +RUN git --version +RUN bzip2 --version +RUN go version + +# --target=vendor +FROM gobase AS govendor +COPY . ./ +ENV GOWORK=off +RUN go mod vendor + +FROM nodebase AS nodevendor +COPY . ./ +# On the nodebase image, the NODE_ENV is set to production, causing npm install +# to omit devDependencies. That would be normally preferred (much less packages +# vendored, avoiding security vuln. for deps used for tests), but Prometheus uses +# some devDependencies for normal build at the moment too e.g. @lezer/generator +# (custom build script), rollup, tsc (TypeScript) and probably more. +# Installing those manually later on is prone to errors, especially across +# different Prometheus versions. +# TODO(bwplotka): Consider moving those deps in upstream to non-dev lists. +ENV NODE_ENV="development" +RUN (cd web/ui && pnpm install) || [ -d web/ui/node_modules/vite ] +RUN (cd web/ui/react-app && pnpm install) || [ -d web/ui/react-app/node_modules/react ] + +FROM scratch AS vendor +COPY --from=govendor /workspace/vendor vendor +COPY --from=nodevendor /workspace/web/ui/node_modules web/ui/node_modules +COPY --from=nodevendor /workspace/web/ui/mantine-ui/node_modules web/ui/mantine-ui/node_modules +COPY --from=nodevendor /workspace/web/ui/module/codemirror-promql/node_modules web/ui/module/codemirror-promql/node_modules +COPY --from=nodevendor /workspace/web/ui/react-app/node_modules web/ui/react-app/node_modules + +# --target=app +# Compile the UI assets. +FROM nodevendor AS assets +RUN (make ui-build) || ( [ -d web/ui/static/react-app ] && [ -d web/ui/static/mantine-ui ] ) +RUN scripts/compress_assets.sh + +# Build the actual Go binary. +FROM gobase AS buildbase +ARG TARGETARCH +ARG TARGETOS +ARG BUILDARCH +COPY --from=assets /workspace ./ +COPY --from=govendor /workspace/vendor vendor +ENV GOEXPERIMENT=boringcrypto +ENV CGO_ENABLED=1 +ENV GOFIPS140=off +ENV GOTOOLCHAIN=local +ENV GOWORK=off +ENV GOARCH=${TARGETARCH} +ENV GOOS=${TARGETOS} +RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ + apt install -y --no-install-recommends \ + gcc-aarch64-linux-gnu libc6-dev-arm64-cross; \ + CC=aarch64-linux-gnu-gcc; \ + fi && \ + go build \ + -tags builtinassets -mod=vendor \ + -ldflags="-X github.com/prometheus/common/version.Version=$(cat VERSION) \ + -X github.com/prometheus/common/version.BuildDate=$(date --iso-8601=seconds)" \ + ./cmd/prometheus && \ + go build \ + -mod=vendor \ + -ldflags="-X github.com/prometheus/common/version.Version=$(cat VERSION) \ + -X github.com/prometheus/common/version.BuildDate=$(date --iso-8601=seconds)" \ + ./cmd/promtool + +# Configure distroless base image like the upstream Prometheus image. +# Since the directory and symlink setup needs shell access, we need yet another +# intermediate stage. +FROM ${IMAGE_BASE_DEBUG} AS appbase + +COPY documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml +RUN ["/busybox/sh", "-c", "mkdir -p /prometheus"] + +FROM ${IMAGE_BASE} AS app + +COPY --from=buildbase /workspace/prometheus /bin/prometheus +COPY --from=buildbase /workspace/promtool /bin/promtool +COPY --from=appbase --chown=nobody:nobody /etc/prometheus /etc/prometheus +COPY --from=appbase --chown=nobody:nobody /prometheus /prometheus +COPY LICENSE /LICENSE +COPY NOTICE /NOTICE + +USER nobody +EXPOSE 9090 +VOLUME [ "/prometheus" ] +ENTRYPOINT [ "/bin/prometheus" ] +CMD [ "--config.file=/etc/prometheus/prometheus.yml", \ + "--storage.tsdb.path=/prometheus" ] diff --git a/Makefile b/Makefile index d1033a2a58..9d7bf06938 100644 --- a/Makefile +++ b/Makefile @@ -211,7 +211,7 @@ update-features-testdata: @echo ">> updating features testdata" @$(GO) test ./cmd/prometheus -run TestFeaturesAPI -update-features -GO_SUBMODULE_DIRS := documentation/examples/remote_storage internal/tools web/ui/mantine-ui/src/promql/tools compliance +GO_SUBMODULE_DIRS := internal/tools web/ui/mantine-ui/src/promql/tools compliance .PHONY: update-all-go-deps update-all-go-deps: update-go-deps diff --git a/README.md b/README.md index 9f644d57dc..ec31405941 100644 --- a/README.md +++ b/README.md @@ -1,228 +1,10 @@ -

- Prometheus
Prometheus -

+## Google Cloud Managed Service for Prometheus (GMP) Fork -

Visit prometheus.io for the full documentation, -examples and guides.

+> NOTICE: This repository is a fork of [github.com/prometheus/prometheus](https://github.com/prometheus/prometheus) that includes support for GMP. +> +> We actively work on ensuring vanilla Prometheus can work with GMP; this fork will +> be significantly reduced. Notably, the custom GCM export will be removed. -
+For GMP specific documentation and to get started, go to [g.co/cloud/managedprometheus](https://g.co/cloud/managedprometheus). -[![CI](https://github.com/prometheus/prometheus/actions/workflows/ci.yml/badge.svg)](https://github.com/prometheus/prometheus/actions/workflows/ci.yml) -[![Docker Repository on Quay](https://quay.io/repository/prometheus/prometheus/status)][quay] -[![Docker Pulls](https://img.shields.io/docker/pulls/prom/prometheus.svg?maxAge=604800)][hub] -[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/prometheus)](https://goreportcard.com/report/github.com/prometheus/prometheus) -[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/486/badge)](https://bestpractices.coreinfrastructure.org/projects/486) -[![govulncheck](https://github.com/prometheus/prometheus/actions/workflows/govulncheck.yml/badge.svg?event=schedule)](https://github.com/prometheus/prometheus/actions/workflows/govulncheck.yml) -[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/prometheus/prometheus/badge)](https://securityscorecards.dev/viewer/?uri=github.com/prometheus/prometheus) -[![CLOMonitor](https://img.shields.io/endpoint?url=https://clomonitor.io/api/projects/cncf/prometheus/badge)](https://clomonitor.io/projects/cncf/prometheus) -[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/prometheus.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:prometheus) - -
- -Prometheus, a [Cloud Native Computing Foundation](https://cncf.io/) project, is a systems and service monitoring system. It collects metrics -from configured targets at given intervals, evaluates rule expressions, -displays the results, and can trigger alerts when specified conditions are observed. - -The features that distinguish Prometheus from other metrics and monitoring systems are: - -* A **multi-dimensional** data model (time series defined by metric name and set of key/value dimensions) -* PromQL, a **powerful and flexible query language** to leverage this dimensionality -* No dependency on distributed storage; **single server nodes are autonomous** -* An HTTP **pull model** for time series collection -* **Pushing time series** is supported via an intermediary gateway for batch jobs -* Targets are discovered via **service discovery** or **static configuration** -* Multiple modes of **graphing and dashboarding support** -* Support for hierarchical and horizontal **federation** - -## Architecture overview - -![Architecture overview](documentation/images/architecture.svg) - -## Install - -There are various ways to install Prometheus. - -### Precompiled binaries - -Precompiled binaries for released versions are available in the -[*download* section](https://prometheus.io/download/) -on [prometheus.io](https://prometheus.io). Using the latest production release binary -is the recommended way to install Prometheus. -See the [Installing](https://prometheus.io/docs/introduction/install/) -chapter in the documentation for all the details. - -### Docker images - -Docker images are available on [Quay.io](https://quay.io/repository/prometheus/prometheus) or [Docker Hub](https://hub.docker.com/r/prom/prometheus/). - -You can launch a Prometheus container for trying it out with - -```bash -docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus -``` - -Prometheus will now be reachable at . - -### Building from source - -To build Prometheus from source code, you need: - -* Go: Version specified in [go.mod](./go.mod) or greater. -* NodeJS: Version specified in [.nvmrc](./web/ui/.nvmrc) or greater. -* npm: Version 10 or greater (check with `npm --version` and [here](https://www.npmjs.com/)). - -Start by cloning the repository: - -```bash -git clone https://github.com/prometheus/prometheus.git -cd prometheus -``` - -You can use the `go` tool to build and install the `prometheus` -and `promtool` binaries into your `GOPATH`: - -```bash -go install github.com/prometheus/prometheus/cmd/... -prometheus --config.file=your_config.yml -``` - -*However*, when using `go install` to build Prometheus, Prometheus will expect to be able to -read its web assets from local filesystem directories under `web/ui/static`. In order for -these assets to be found, you will have to run Prometheus from the root of the cloned -repository. Note also that this directory does not include the React UI unless it has been -built explicitly using `make assets` or `make build`. - -An example of the above configuration file can be found [here.](https://github.com/prometheus/prometheus/blob/main/documentation/examples/prometheus.yml) - -You can also build using `make build`, which will compile in the web assets so that -Prometheus can be run from anywhere: - -```bash -make build -./prometheus --config.file=your_config.yml -``` - -The Makefile provides several targets: - -* *build*: build the `prometheus` and `promtool` binaries (includes building and compiling in web assets) -* *test*: run the tests -* *test-short*: run the short tests -* *format*: format the source code -* *vet*: check the source code for common errors -* *assets*: build the React UI - -### Service discovery plugins - -Prometheus is bundled with many service discovery plugins. You can customize -which service discoveries are included in your build using Go build tags. - -To exclude service discoveries when building with `make build`, add the desired -tags to the `.promu.yml` file under `build.tags.all`: - -```yaml -build: - tags: - all: - - netgo - - builtinassets - - remove_all_sd # Exclude all optional SDs - - enable_kubernetes_sd # Re-enable only kubernetes -``` - -Then run `make build` as usual. Alternatively, when using `go build` directly: - -```bash -go build -tags "remove_all_sd,enable_kubernetes_sd" ./cmd/prometheus -``` - -Available build tags: -* `remove_all_sd` - Exclude all optional service discoveries (keeps file_sd, static_sd, and http_sd) -* `enable__sd` - Re-enable a specific SD when using `remove_all_sd` - -If you add out-of-tree plugins, which we do not endorse at the moment, -additional steps might be needed to adjust the `go.mod` and `go.sum` files. As -always, be extra careful when loading third party code. - -### Building the Docker image - -You can build a docker image locally with the following commands: - -```bash -make promu -promu crossbuild -p linux/amd64 -make common-docker-amd64 -``` - -The `make docker` target is intended only for use in our CI system and will not -produce a fully working image when run locally. - -## Using Prometheus as a Go Library - -Within the Prometheus project, repositories such as [prometheus/common](https://github.com/prometheus/common) and -[prometheus/client-golang](https://github.com/prometheus/client-golang) are designed as re-usable libraries. - -The [prometheus/prometheus](https://github.com/prometheus/prometheus) repository builds a stand-alone program and is not -designed for use as a library. We are aware that people do use parts as such, -and we do not put any deliberate inconvenience in the way, but we want you to be -aware that no care has been taken to make it work well as a library. For instance, -you may encounter errors that only surface when used as a library. - -### Remote Write - -We are publishing our Remote Write protobuf independently at -[buf.build](https://buf.build/prometheus/prometheus/assets). - -You can use that as a library: - -```shell -go get buf.build/gen/go/prometheus/prometheus/protocolbuffers/go@latest -``` - -This is experimental. - -### Prometheus code base - -In order to comply with [go mod](https://go.dev/ref/mod#versions) rules, -Prometheus release number do not exactly match Go module releases. - -For the -Prometheus v3.y.z releases, we are publishing equivalent v0.3y.z tags. The y in v0.3y.z is always padded to two digits, with a leading zero if needed. - -Therefore, a user that would want to use Prometheus v3.0.0 as a library could do: - -```shell -go get github.com/prometheus/prometheus@v0.300.0 -``` - -For the -Prometheus v2.y.z releases, we published the equivalent v0.y.z tags. - -Therefore, a user that would want to use Prometheus v2.35.0 as a library could do: - -```shell -go get github.com/prometheus/prometheus@v0.35.0 -``` - -This solution makes it clear that we might break our internal Go APIs between -minor user-facing releases, as [breaking changes are allowed in major version -zero](https://semver.org/#spec-item-4). - -## React UI Development - -For more information on building, running, and developing on the React-based UI, see the React app's [README.md](web/ui/README.md). - -## More information - -* Godoc documentation is available via [pkg.go.dev](https://pkg.go.dev/github.com/prometheus/prometheus). Due to peculiarities of Go Modules, v3.y.z will be displayed as v0.3y.z (the y in v0.3y.z is always padded to two digits, with a leading zero if needed), while v2.y.z will be displayed as v0.y.z. -* See the [Community page](https://prometheus.io/community) for how to reach the Prometheus developers and users on various communication channels. - -## Contributing - -Refer to [CONTRIBUTING.md](https://github.com/prometheus/prometheus/blob/main/CONTRIBUTING.md) - -## License - -Apache License 2.0, see [LICENSE](https://github.com/prometheus/prometheus/blob/main/LICENSE). - -[hub]: https://hub.docker.com/r/prom/prometheus/ -[quay]: https://quay.io/repository/prometheus/prometheus +Otherwise, refer to https://github.com/prometheus/prometheus documentation. diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 6795c6bb4c..56418325bf 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -36,23 +36,30 @@ import ( "strings" "sync" "syscall" + "testing" "time" "github.com/KimMachineGun/automemlimit/memlimit" "github.com/alecthomas/kingpin/v2" "github.com/alecthomas/units" + gokitlog "github.com/go-kit/log" "github.com/grafana/regexp" "github.com/mwitkow/go-conntrack" "github.com/oklog/run" + "github.com/oklog/ulid" remoteapi "github.com/prometheus/client_golang/exp/api/remote" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version" + common_config "github.com/prometheus/common/config" "github.com/prometheus/common/model" "github.com/prometheus/common/promslog" promslogflag "github.com/prometheus/common/promslog/flag" "github.com/prometheus/common/version" toolkit_web "github.com/prometheus/exporter-toolkit/web" + "github.com/prometheus/prometheus/google/export" + gcm_export "github.com/prometheus/prometheus/google/export/setup" + "github.com/prometheus/prometheus/google/secrets" "go.uber.org/atomic" "go.uber.org/automaxprocs/maxprocs" "k8s.io/client-go/rest" @@ -128,6 +135,36 @@ func (klogv1Writer) Write(p []byte) (n int, err error) { return len(p), nil } +type slogToGoKitAdapter struct { + logger *slog.Logger +} + +func (a slogToGoKitAdapter) Log(keyvals ...any) error { + var msg string + var args []any + for i := 0; i < len(keyvals); i += 2 { + key, _ := keyvals[i].(string) + var val any + if i+1 < len(keyvals) { + val = keyvals[i+1] + } + if key == "msg" { + msg, _ = val.(string) + } else { + args = append(args, key, val) + } + } + a.logger.Info(msg, args...) + return nil +} + +func toGoKitLog(logger *slog.Logger) gokitlog.Logger { + if logger == nil { + return gokitlog.NewNopLogger() + } + return slogToGoKitAdapter{logger: logger} +} + var ( appName = "prometheus" @@ -216,6 +253,7 @@ type flagConfig struct { enablePerStepStats bool enableConcurrentRuleEval bool useStartTimestamps bool + enableKubeSecretProvider bool prometheusURL string corsRegexString string @@ -312,6 +350,11 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error { case "promql-binop-fill-modifiers": c.parserOpts.EnableBinopFillModifiers = true logger.Info("Experimental PromQL binary operator fill modifiers enabled.") + case "google-kubernetes-secret-provider": + c.enableKubeSecretProvider = true + logger.Info("Experimental (Google) Kubernetes secret provider enabled.") + case "": + continue case "old-ui": c.web.UseOldUI = true logger.Info("Serving previous version of the Prometheus web UI.") @@ -642,8 +685,11 @@ func main() { a.Flag("agent", "Run Prometheus in 'Agent mode'.").BoolVar(&agentMode) promslogflag.AddFlags(a, &cfg.promslogConfig) - a.Flag("write-documentation", "Generate command line documentation. Internal use.").Hidden().Action(func(*kingpin.ParseContext) error { + // Set defaults to empty to ensure this command is deterministic. + a.GetFlag("export.label.project-id").Default("") + a.GetFlag("export.label.cluster").Default("") + a.GetFlag("export.label.location").Default("") if err := documentcli.GenerateMarkdown(a.Model(), os.Stdout); err != nil { os.Exit(1) return err @@ -652,7 +698,26 @@ func main() { return nil }).Bool() - _, err := a.Parse(os.Args[1:]) + // GMP fork flags. + var deleteDataOnStart bool + a.Flag("gmp.storage.delete-data-on-start", "[GMP fork experimental flag] If true, all the storage related data (e.g. blocks, lock file, WAL, head chunks) in the --storage.tsdb.path or --storage.agent.path (depending on the mode) will be deleted, right before opening the DB. As a result, all previously collected samples will be uncoverably dropped. Use it in setups where the availability is more important than the persistence between restarts, as replaying data can take time and resources. This flag is especially useful on Kubernetes with ephemeral storage (for consistency between pod vs container restart), remote write use cases that prioritize live data and when you want to auto-recover from the OOM crashloops without changing memory limits for Prometheus (see https://github.com/prometheus/prometheus/issues/13939)."). + Default("false").BoolVar(&deleteDataOnStart) + + opts := gcm_export.Opts{ + ExporterOpts: export.ExporterOpts{ + UserAgentProduct: fmt.Sprintf("prometheus/%s", version.Version), + Disable: testing.Testing(), + }, + } + opts.SetupFlags(a) + + extraArgs, err := gcm_export.ExtraArgs() + if err != nil { + fmt.Fprintln(os.Stderr, fmt.Errorf("Error parsing commandline arguments: %w", err)) + a.Usage(os.Args[1:]) + os.Exit(2) + } + _, err = a.Parse(append(os.Args[1:], extraArgs...)) if err != nil { fmt.Fprintf(os.Stderr, "Error parsing command line arguments: %s\n", err) a.Usage(os.Args[1:]) @@ -711,6 +776,16 @@ func main() { localStoragePath = cfg.agentStoragePath } + // NOTE(bwplotka): This opt-in functionality exists in our fork, relevant + // discussion in the upstream is here: https://github.com/prometheus/prometheus/issues/13939 + if deleteDataOnStart { + logger.Info("The --gmp.storage.delete-data-on-start flag was set, deleting relevant storage files in the storage path", "path", localStoragePath) + if err := deleteStorageData(agentMode, localStoragePath); err != nil { + fmt.Fprintln(os.Stderr, fmt.Errorf("failed to delete storage data as requested: %w", err)) + os.Exit(1) + } + } + cfg.web.ExternalURL, err = computeExternalURL(cfg.prometheusURL, cfg.web.ListenAddresses[0]) if err != nil { fmt.Fprintln(os.Stderr, fmt.Errorf("parse external URL %q: %w", cfg.prometheusURL, err)) @@ -921,6 +996,7 @@ func main() { var ( ctxWeb, cancelWeb = context.WithCancel(context.Background()) ctxRule = context.Background() + ctxSecrets = context.Background() notifierManager = notifier.NewManager(&cfg.notifier, cfgFile.GlobalConfig.MetricNameValidationScheme, logger.With("component", "notifier")) @@ -971,6 +1047,21 @@ func main() { os.Exit(1) } + var secretManager *secrets.Manager + if cfg.enableKubeSecretProvider { + manager := secrets.NewManager( + ctxSecrets, + prometheus.DefaultRegisterer, + secrets.ProviderOptions{ + Logger: gokitlog.With(toGoKitLog(logger), "component", "secret manager"), + }, + ) + secretManager = &manager + defer secretManager.Close(prometheus.DefaultRegisterer) + + cfg.scrape.HTTPClientOptions = append(cfg.scrape.HTTPClientOptions, common_config.WithSecretManager(secretManager)) + } + var ( tracingManager = tracing.NewManager(logger) @@ -1144,6 +1235,20 @@ func main() { } return discoveryManagerScrape.ApplyConfig(c) }, + }, { + name: "secret", + reloader: func(cfg *config.Config) error { + if secretManager == nil { + if len(cfg.SecretConfigs) > 0 { + return errors.New("secret providers are disabled") + } + return nil + } + kConfig := secrets.WatchSPConfig{ + ClientConfig: cfg.ClientConfig, + } + return secretManager.ApplyConfig(&kConfig, cfg.SecretConfigs) + }, }, { name: "notify", reloader: notifierManager.ApplyConfig, @@ -1185,6 +1290,12 @@ func main() { }, { name: "tracing", reloader: tracingManager.ApplyConfig, + }, { + name: "gcm_export", + reloader: func(cfg *config.Config) error { + // Call in closure to not call Global() before it's initialized below. + return gcm_export.Global().ApplyConfig(cfg) + }, }, } @@ -1250,6 +1361,29 @@ func main() { }, ) } + { + exporterLogger := gokitlog.With(toGoKitLog(logger), "component", "gcm_exporter") + ctx, cancel := context.WithCancel(context.Background()) + exporter, err := opts.NewExporter(ctx, exporterLogger, prometheus.DefaultRegisterer) + if err != nil { + logger.Error("Unable to init Google Cloud Monitoring exporter", "err", err) + os.Exit(2) + } + + if err := gcm_export.SetGlobal(exporter); err != nil { + logger.Error("Unable to set Google Cloud Monitoring exporter", "err", err) + os.Exit(2) + } + + g.Add( + func() error { + return gcm_export.Global().Run() + }, + func(err error) { + cancel() + }, + ) + } { // Scrape discovery manager. g.Add( @@ -1733,7 +1867,7 @@ func updateGoGC(conf *config.Config, logger *slog.Logger) { func startsOrEndsWithQuote(s string) bool { return strings.HasPrefix(s, "\"") || strings.HasPrefix(s, "'") || - strings.HasSuffix(s, "\"") || strings.HasSuffix(s, "'") + strings.HasSuffix(s, "\"") || strings.HasSuffix(s, "'") } // compileCORSRegexString compiles given string and adds anchors. @@ -2247,3 +2381,38 @@ func exludeBlocksPendingUpload(logger *slog.Logger, uploadMetaPath string) tsdb. return !slices.Contains(uploadMeta.Uploaded, meta.ULID.String()) } } + +func deleteStorageData(agentMode bool, dataPath string) error { + if agentMode { + for _, f := range []string{"wal", "lock"} { + if err := os.RemoveAll(filepath.Join(dataPath, f)); err != nil { + return err + } + } + return nil + } + + files, err := os.ReadDir(dataPath) + if err != nil { + if os.IsNotExist(err) { + return nil + } + return fmt.Errorf("can't read dir %v: %w", dataPath, err) + } + for _, f := range files { + switch f.Name() { + case "wal", "lock", "chunks_head": + if err := os.RemoveAll(filepath.Join(dataPath, f.Name())); err != nil { + return err + } + continue + } + if _, err := ulid.Parse(f.Name()); err == nil { + // It's a TSDB block, remove. + if err := os.RemoveAll(filepath.Join(dataPath, f.Name())); err != nil { + return err + } + } + } + return nil +} diff --git a/cmd/prometheus/main_test.go b/cmd/prometheus/main_test.go index 216bb882c8..4cb7b53791 100644 --- a/cmd/prometheus/main_test.go +++ b/cmd/prometheus/main_test.go @@ -138,7 +138,7 @@ func TestFailedStartupExitCode(t *testing.T) { fakeInputFile := "fake-input-file" expectedExitStatus := 2 - prom := exec.Command(promPath, "-test.main", "--web.listen-address=0.0.0.0:0", "--config.file="+fakeInputFile) + prom := exec.Command(promPath, "-test.main", "--web.listen-address=0.0.0.0:0", "--config.file="+fakeInputFile, "--export.debug.disable-auth") err := prom.Run() require.Error(t, err) @@ -289,7 +289,7 @@ func TestWALSegmentSizeBounds(t *testing.T) { } { t.Run(tc.size, func(t *testing.T) { t.Parallel() - prom := exec.Command(promPath, "-test.main", "--storage.tsdb.wal-segment-size="+tc.size, "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--storage.tsdb.path="+filepath.Join(t.TempDir(), "data")) + prom := exec.Command(promPath, "-test.main", "--storage.tsdb.wal-segment-size="+tc.size, "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--storage.tsdb.path="+filepath.Join(t.TempDir(), "data"), "--export.debug.disable-auth") // Log stderr in case of failure. stderr, err := prom.StderrPipe() @@ -353,7 +353,7 @@ func TestMaxBlockChunkSegmentSizeBounds(t *testing.T) { } { t.Run(tc.size, func(t *testing.T) { t.Parallel() - prom := exec.Command(promPath, "-test.main", "--storage.tsdb.max-block-chunk-segment-size="+tc.size, "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--storage.tsdb.path="+filepath.Join(t.TempDir(), "data")) + prom := exec.Command(promPath, "-test.main", "--storage.tsdb.max-block-chunk-segment-size="+tc.size, "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--storage.tsdb.path="+filepath.Join(t.TempDir(), "data"), "--export.debug.disable-auth") // Log stderr in case of failure. stderr, err := prom.StderrPipe() @@ -560,10 +560,75 @@ func getCurrentGaugeValuesFor(t *testing.T, reg prometheus.Gatherer, metricNames return res } +func TestDeleteStorageDataOnStart(t *testing.T) { + for _, agentMode := range []bool{false, true} { + t.Run(fmt.Sprintf("%v", agentMode), func(t *testing.T) { + t.Run("empty", func(t *testing.T) { + dir := t.TempDir() + + require.NoError(t, deleteStorageData(agentMode, dir)) + requireEmptyDir(t, dir) + }) + t.Run("partial data", func(t *testing.T) { + dir := t.TempDir() + + if !agentMode { + require.NoError(t, os.Mkdir(filepath.Join(dir, "chunks_head"), os.ModePerm)) + } + require.NoError(t, os.Mkdir(filepath.Join(dir, "wal"), os.ModePerm)) + require.NoError(t, os.Mkdir(filepath.Join(dir, "wal", "checkpoint.00000003"), os.ModePerm)) + + require.NoError(t, deleteStorageData(agentMode, dir)) + requireEmptyDir(t, dir) + }) + t.Run("full data", func(t *testing.T) { + dir := t.TempDir() + + if !agentMode { + require.NoError(t, os.Mkdir(filepath.Join(dir, "chunks_head"), os.ModePerm)) + require.NoError(t, os.Mkdir(filepath.Join(dir, "01HTHFTV0ZK2KQ85DXQK9TGA7Z"), os.ModePerm)) + + } + require.NoError(t, os.Mkdir(filepath.Join(dir, "wal"), os.ModePerm)) + require.NoError(t, os.Mkdir(filepath.Join(dir, "wal", "checkpoint.00000003"), os.ModePerm)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "lock"), []byte{1}, os.ModePerm)) + + require.NoError(t, deleteStorageData(agentMode, dir)) + requireEmptyDir(t, dir) + }) + }) + } +} + +func requireEmptyDir(t *testing.T, dir string) { + t.Helper() + files, err := os.ReadDir(dir) + require.NoError(t, err) + require.Empty(t, files, "%v contains unexpected files", dir) +} + +func TestAgentDeleteDataOnStart(t *testing.T) { + prom := exec.Command(promPath, "-test.main", "--enable-feature=agent", "--web.listen-address=0.0.0.0:0", "--config.file="+agentConfig, "--export.debug.disable-auth") + require.NoError(t, prom.Start()) + + actualExitStatus := 0 + done := make(chan error, 1) + + go func() { done <- prom.Wait() }() + select { + case err := <-done: + t.Logf("prometheus agent should be still running: %v", err) + actualExitStatus = prom.ProcessState.ExitCode() + case <-time.After(startupTime): + prom.Process.Kill() + } + require.Equal(t, 0, actualExitStatus) +} + func TestAgentSuccessfulStartup(t *testing.T) { t.Parallel() - prom := exec.Command(promPath, "-test.main", "--agent", "--web.listen-address=0.0.0.0:0", "--config.file="+agentConfig) + prom := exec.Command(promPath, "-test.main", "--agent", "--web.listen-address=0.0.0.0:0", "--config.file="+agentConfig, "--export.debug.disable-auth") require.NoError(t, prom.Start()) actualExitStatus := 0 @@ -583,7 +648,7 @@ func TestAgentSuccessfulStartup(t *testing.T) { func TestAgentFailedStartupWithServerFlag(t *testing.T) { t.Parallel() - prom := exec.Command(promPath, "-test.main", "--agent", "--storage.tsdb.path=.", "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig) + prom := exec.Command(promPath, "-test.main", "--agent", "--storage.tsdb.path=.", "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--export.debug.disable-auth") output := bytes.Buffer{} prom.Stderr = &output @@ -612,7 +677,7 @@ func TestAgentFailedStartupWithServerFlag(t *testing.T) { func TestAgentFailedStartupWithInvalidConfig(t *testing.T) { t.Parallel() - prom := exec.Command(promPath, "-test.main", "--agent", "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig) + prom := exec.Command(promPath, "-test.main", "--agent", "--web.listen-address=0.0.0.0:0", "--config.file="+promConfig, "--export.debug.disable-auth") require.NoError(t, prom.Start()) actualExitStatus := 0 @@ -649,7 +714,7 @@ func TestModeSpecificFlags(t *testing.T) { for _, tc := range testcases { t.Run(fmt.Sprintf("%s mode with option %s", tc.mode, tc.arg), func(t *testing.T) { t.Parallel() - args := []string{"-test.main", tc.arg, t.TempDir(), "--web.listen-address=0.0.0.0:0"} + args := []string{"-test.main", tc.arg, t.TempDir(), "--web.listen-address=0.0.0.0:0", "--export.debug.disable-auth"} if tc.mode == "agent" { args = append(args, "--agent", "--config.file="+agentConfig) @@ -704,6 +769,8 @@ func TestModeSpecificFlags(t *testing.T) { } func TestDocumentation(t *testing.T) { + t.Skip("google: We don't maintain docs in our fork, so nothing to regenerate and test.") + if runtime.GOOS == "windows" { t.SkipNow() } @@ -1211,6 +1278,8 @@ remote_write: // TestFeatureFlagsDocumented ensures the --enable-feature help text in main.go // and the documented flags in docs/feature_flags.md list the same set of flags. func TestFeatureFlagsDocumented(t *testing.T) { + t.Skip("google: We don't maintain docs in our fork, so nothing to regenerate and test.") + if runtime.GOOS == "windows" { t.SkipNow() } diff --git a/cmd/prometheus/main_unix_test.go b/cmd/prometheus/main_unix_test.go index ea130b3bf9..e8cb97c061 100644 --- a/cmd/prometheus/main_unix_test.go +++ b/cmd/prometheus/main_unix_test.go @@ -38,7 +38,7 @@ func TestStartupInterrupt(t *testing.T) { port := fmt.Sprintf(":%d", testutil.RandomUnprivilegedPort(t)) - prom := exec.Command(promPath, "-test.main", "--config.file="+promConfig, "--storage.tsdb.path="+t.TempDir(), "--web.listen-address=0.0.0.0"+port) + prom := exec.Command(promPath, "-test.main", "--config.file="+promConfig, "--storage.tsdb.path="+t.TempDir(), "--web.listen-address=0.0.0.0"+port, "--export.debug.disable-auth") err := prom.Start() require.NoError(t, err) diff --git a/cmd/prometheus/query_log_test.go b/cmd/prometheus/query_log_test.go index b3fd5e1bdb..918f751d43 100644 --- a/cmd/prometheus/query_log_test.go +++ b/cmd/prometheus/query_log_test.go @@ -87,8 +87,14 @@ func (p *queryLogTest) setQueryLog(t *testing.T, queryLogFile string) { require.NoError(t, err) _, err = p.configFile.Seek(0, 0) require.NoError(t, err) + commonGlobal := ` + # GMP requires settings project_id and location labels. + external_labels: + project_id: example-project + location: us-central-1 +` if queryLogFile != "" { - _, err = fmt.Fprintf(p.configFile, "global:\n query_log_file: %s\n", queryLogFile) + _, err = fmt.Fprintf(p.configFile, "global:\n query_log_file: %s\n%s", queryLogFile, commonGlobal) require.NoError(t, err) } _, err = p.configFile.Write([]byte(p.configuration())) @@ -298,6 +304,7 @@ func (p *queryLogTest) run(t *testing.T) { "--web.enable-lifecycle", fmt.Sprintf("--web.listen-address=%s:%d", p.host, p.port), "--storage.tsdb.path=" + dir, + "--export.debug.disable-auth", }, p.params()...) prom := exec.Command(promPath, params...) diff --git a/cmd/promtool/main_test.go b/cmd/promtool/main_test.go index e42ca69441..a0f4694a3b 100644 --- a/cmd/promtool/main_test.go +++ b/cmd/promtool/main_test.go @@ -603,6 +603,8 @@ func TestExitCodes(t *testing.T) { } func TestDocumentation(t *testing.T) { + t.Skip("google: We don't maintain docs in our fork, so nothing to regenerate and test.") + if runtime.GOOS == "windows" { t.SkipNow() } diff --git a/config/config.go b/config/config.go index cdf914b891..cf8a3350be 100644 --- a/config/config.go +++ b/config/config.go @@ -33,6 +33,8 @@ import ( "github.com/prometheus/common/config" "github.com/prometheus/common/model" "github.com/prometheus/otlptranslator" + gcm_exportconfig "github.com/prometheus/prometheus/google/config" + gcm_secrets "github.com/prometheus/prometheus/google/secrets" "github.com/prometheus/sigv4" "go.yaml.in/yaml/v2" @@ -299,10 +301,16 @@ type Config struct { StorageConfig StorageConfig `yaml:"storage,omitempty"` TracingConfig TracingConfig `yaml:"tracing,omitempty"` + // Secret management: + gcm_secrets.ClientConfig `yaml:"kubernetes_sp_config,omitempty"` + SecretConfigs []gcm_secrets.SecretConfig `yaml:"kubernetes_secrets,omitempty"` + RemoteWriteConfigs []*RemoteWriteConfig `yaml:"remote_write,omitempty"` RemoteReadConfigs []*RemoteReadConfig `yaml:"remote_read,omitempty"` OTLPConfig OTLPConfig `yaml:"otlp,omitempty"` + GoogleCloud gcm_exportconfig.GoogleCloudConfig `yaml:"google_cloud,omitempty"` + loaded bool // Certain methods require configuration to use Load validation. } diff --git a/docs/command-line/index.md b/docs/command-line/index.md deleted file mode 100644 index 53786fbb20..0000000000 --- a/docs/command-line/index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Command Line -sort_rank: 9 ---- diff --git a/docs/command-line/prometheus.md b/docs/command-line/prometheus.md deleted file mode 100644 index 5ec738e768..0000000000 --- a/docs/command-line/prometheus.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: prometheus ---- - -The Prometheus monitoring server - - -## Flags - -| Flag | Description | Default | -| --- | --- | --- | -| -h, --help | Show context-sensitive help (also try --help-long and --help-man). | | -| --version | Show application version. | | -| --config.file | Prometheus configuration file path. | `prometheus.yml` | -| --config.auto-reload | Enable automatic configuration file reloading. See also --config.auto-reload-interval. | `false` | -| --config.auto-reload-interval | Specifies the interval for checking and automatically reloading the Prometheus configuration file upon detecting changes. Only used when --config.auto-reload is set. | `30s` | -| --web.listen-address ... | Address to listen on for UI, API, and telemetry. Can be repeated. | `0.0.0.0:9090` | -| --auto-gomaxprocs | Automatically set GOMAXPROCS to match Linux container CPU quota | `true` | -| --auto-gomemlimit | Automatically set GOMEMLIMIT to match Linux container or system memory limit | `true` | -| --auto-gomemlimit.ratio | The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory | `0.9` | -| --web.config.file | [EXPERIMENTAL] Path to configuration file that can enable TLS or authentication. | | -| --web.read-timeout | Maximum duration before timing out read of the request, and closing idle connections. | `5m` | -| --web.max-connections | Maximum number of simultaneous connections across all listeners. | `512` | -| --web.max-notifications-subscribers | Limits the maximum number of subscribers that can concurrently receive live notifications. If the limit is reached, new subscription requests will be denied until existing connections close. | `16` | -| --web.external-url | The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically. | | -| --web.route-prefix | Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url. | | -| --web.user-assets | Path to static asset directory, available at /user. | | -| --web.enable-lifecycle | Enable shutdown and reload via HTTP request. | `false` | -| --web.enable-admin-api | Enable API endpoints for admin control actions. | `false` | -| --web.enable-remote-write-receiver | Enable API endpoint accepting remote write requests. | `false` | -| --web.remote-write-receiver.accepted-protobuf-messages | List of the remote write protobuf messages to accept when receiving the remote writes. Supported values: prometheus.WriteRequest, io.prometheus.write.v2.Request | `prometheus.WriteRequest` | -| --web.enable-otlp-receiver | Enable API endpoint accepting OTLP write requests. | `false` | -| --web.console.templates | Path to the console template directory, available at /consoles. | `consoles` | -| --web.console.libraries | Path to the console library directory. | `console_libraries` | -| --web.page-title | Document title of Prometheus instance. | `Prometheus Time Series Collection and Processing Server` | -| --web.cors.origin | Regex for CORS origin. It is fully anchored. Example: 'https?://(domain1\|domain2)\.com' | `.*` | -| --storage.tsdb.path | Base path for metrics storage. Use with server mode only. | `data/` | -| --storage.tsdb.retention.time | [DEPRECATED] How long to retain samples in storage. If neither this flag nor "storage.tsdb.retention.size" is set, the retention time defaults to 15d. Units Supported: y, w, d, h, m, s, ms. This flag has been deprecated, use the storage.tsdb.retention.time field in the config file instead. Use with server mode only. | | -| --storage.tsdb.retention.size | [DEPRECATED] Maximum number of bytes that can be stored for blocks. A unit is required, supported units: B, KB, MB, GB, TB, PB, EB. Ex: "512MB". Based on powers-of-2, so 1KB is 1024B. This flag has been deprecated, use the storage.tsdb.retention.size field in the config file instead. Use with server mode only. | | -| --storage.tsdb.no-lockfile | Do not create lockfile in data directory. Use with server mode only. | `false` | -| --storage.tsdb.head-chunks-write-queue-size | Size of the queue through which head chunks are written to the disk to be m-mapped, 0 disables the queue completely. Experimental. Use with server mode only. | `0` | -| --storage.tsdb.delay-compact-file.path | Path to a JSON file with uploaded TSDB blocks e.g. Thanos shipper meta file. If set TSDB will only compact 1 level blocks that are marked as uploaded in that file, improving external storage integrations e.g. with Thanos sidecar. 1+ level compactions won't be delayed. Use with server mode only. | | -| --storage.agent.path | Base path for metrics storage. Use with agent mode only. | `data-agent/` | -| --storage.agent.wal-compression | Compress the agent WAL. If false, the --storage.agent.wal-compression-type flag is ignored. Use with agent mode only. | `true` | -| --storage.agent.retention.min-time | Minimum age samples may be before being considered for deletion when the WAL is truncated Use with agent mode only. | `5m` | -| --storage.agent.retention.max-time | Maximum age samples may be before being forcibly deleted when the WAL is truncated Use with agent mode only. | `4h` | -| --storage.agent.checkpoint-from-in-memory-series | Use only in-memory series data when building a checkpoint. Use with agent mode only. | `false` | -| --storage.agent.checkpoint-batch-size | Size of a single WAL log entry chunk to be flushed. Has no effect without --storage.agent.checkpoint-from-in-memory-series flag. Use with agent mode only. | `1000` | -| --storage.agent.no-lockfile | Do not create lockfile in data directory. Use with agent mode only. | `false` | -| --storage.remote.flush-deadline | How long to wait flushing sample on shutdown or config reload. | `1m` | -| --storage.remote.read-sample-limit | Maximum overall number of samples to return via the remote read interface, in a single query. 0 means no limit. This limit is ignored for streamed response types. Use with server mode only. | `5e7` | -| --storage.remote.read-concurrent-limit | Maximum number of concurrent remote read calls. 0 means no limit. Use with server mode only. | `10` | -| --storage.remote.read-max-bytes-in-frame | Maximum number of bytes in a single frame for streaming remote read response types before marshalling. Note that client might have limit on frame size as well. 1MB as recommended by protobuf by default. Use with server mode only. | `1048576` | -| --web.search.max-limit | Hard upper bound on the "limit" query parameter accepted by the experimental search API (--enable-feature=search-api). Requests with a higher limit are rejected with HTTP 400. 0 disables the cap. Use with server mode only. | `10000` | -| --rules.alert.for-outage-tolerance | Max time to tolerate prometheus outage for restoring "for" state of alert. Use with server mode only. | `1h` | -| --rules.alert.for-grace-period | Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period. Use with server mode only. | `10m` | -| --rules.alert.resend-delay | Minimum amount of time to wait before resending an alert to Alertmanager. Use with server mode only. | `1m` | -| --rules.max-concurrent-evals | Global concurrency limit for independent rules that can run concurrently. When set, "query.max-concurrency" may need to be adjusted accordingly. Use with server mode only. | `4` | -| --alertmanager.notification-queue-capacity | The capacity of the queue for pending Alertmanager notifications. Use with server mode only. | `10000` | -| --alertmanager.notification-batch-size | The maximum number of notifications per batch to send to the Alertmanager. Use with server mode only. | `256` | -| --alertmanager.drain-notification-queue-on-shutdown | Send any outstanding Alertmanager notifications when shutting down. If false, any outstanding Alertmanager notifications will be dropped when shutting down. Use with server mode only. | `true` | -| --query.lookback-delta | The maximum lookback duration for retrieving metrics during expression evaluations and federation. Use with server mode only. | `5m` | -| --query.timeout | Maximum time a query may take before being aborted. Use with server mode only. | `2m` | -| --query.max-concurrency | Maximum number of queries executed concurrently. Use with server mode only. | `20` | -| --query.max-samples | Maximum number of samples a single query can load into memory. Note that queries will fail if they try to load more samples than this into memory, so this also limits the number of samples a query can return. Use with server mode only. | `50000000` | -| --enable-feature ... | Comma separated feature names to enable. Valid options: concurrent-rule-eval, created-timestamp-zero-ingestion, delayed-compaction, exemplar-storage, extra-scrape-metrics, memory-snapshot-on-shutdown, metadata-wal-records, old-ui, otlp-deltatocumulative, otlp-native-delta-ingestion, promql-binop-fill-modifiers, promql-delayed-name-removal, promql-duration-expr, promql-experimental-functions, promql-extended-range-selectors, promql-per-step-stats, search-api, st-storage, st-synthesis, type-and-unit-labels, use-start-timestamps, use-uncached-io, xor2-encoding. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details. | | -| --agent | Run Prometheus in 'Agent mode'. | | -| --log.level | Only log messages with the given severity or above. One of: [debug, info, warn, error] | `info` | -| --log.format | Output format of log messages. One of: [logfmt, json] | `logfmt` | - - diff --git a/docs/command-line/promtool.md b/docs/command-line/promtool.md deleted file mode 100644 index 06c6f87874..0000000000 --- a/docs/command-line/promtool.md +++ /dev/null @@ -1,774 +0,0 @@ ---- -title: promtool ---- - -Tooling for the Prometheus monitoring system. - - -## Flags - -| Flag | Description | -| --- | --- | -| -h, --help | Show context-sensitive help (also try --help-long and --help-man). | -| --version | Show application version. | -| --experimental | Enable experimental commands. | -| --enable-feature ... | Comma separated feature names to enable. Valid options: promql-experimental-functions, promql-delayed-name-removal, promql-duration-expr, promql-extended-range-selectors. See https://prometheus.io/docs/prometheus/latest/feature_flags/ for more details | - - - - -## Commands - -| Command | Description | -| --- | --- | -| help | Show help. | -| check | Check the resources for validity. | -| query | Run query against a Prometheus server. | -| debug | Fetch debug information. | -| push | Push to a Prometheus server. | -| test | Unit testing. | -| tsdb | Run tsdb commands. | -| promql | PromQL formatting and editing. Requires the --experimental flag. | - - - - -### `promtool help` - -Show help. - - - -#### Arguments - -| Argument | Description | -| --- | --- | -| command | Show help on command. | - - - - -### `promtool check` - -Check the resources for validity. - - - -#### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --query.lookback-delta | The server's maximum query lookback duration. | `5m` | - - - - -##### `promtool check service-discovery` - -Perform service discovery for the given job name and report the results, including relabeling. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --timeout | The time to wait for discovery results. | `30s` | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| config-file | The prometheus config file. | Yes | -| job | The job to run service discovery for. | Yes | - - - - -##### `promtool check config` - -Check if the config files are valid or not. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --syntax-only | Only check the config file syntax, ignoring file and content validation referenced in the config | | -| --lint | Linting checks to apply to the rules/scrape configs specified in the config. Available options are: all, duplicate-rules, none, too-long-scrape-interval. Use --lint=none to disable linting | `duplicate-rules` | -| --lint-fatal | Make lint errors exit with exit code 3. | `false` | -| --ignore-unknown-fields | Ignore unknown fields in the rule groups read by the config files. This is useful when you want to extend rule files with custom metadata. Ensure that those fields are removed before loading them into the Prometheus server as it performs strict checks by default. | `false` | -| --agent | Check config file for Prometheus in Agent mode. | | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| config-files | The config files to check. | Yes | - - - - -##### `promtool check web-config` - -Check if the web config files are valid or not. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| web-config-files | The config files to check. | Yes | - - - - -##### `promtool check healthy` - -Check if the Prometheus server is healthy. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --http.config.file | HTTP client configuration file, see details at https://prometheus.io/docs/prometheus/latest/configuration/promtool | | -| --url | The URL for the Prometheus server. | `http://localhost:9090` | - - - - -##### `promtool check ready` - -Check if the Prometheus server is ready. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --http.config.file | HTTP client configuration file, see details at https://prometheus.io/docs/prometheus/latest/configuration/promtool | | -| --url | The URL for the Prometheus server. | `http://localhost:9090` | - - - - -##### `promtool check rules` - -Check if the rule files are valid or not. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --lint | Linting checks to apply. Available options are: all, duplicate-rules, none. Use --lint=none to disable linting | `duplicate-rules` | -| --lint-fatal | Make lint errors exit with exit code 3. | `false` | -| --ignore-unknown-fields | Ignore unknown fields in the rule files. This is useful when you want to extend rule files with custom metadata. Ensure that those fields are removed before loading them into the Prometheus server as it performs strict checks by default. | `false` | - - - - -###### Arguments - -| Argument | Description | -| --- | --- | -| rule-files | The rule files to check, default is read from standard input. | - - - - -##### `promtool check metrics` - -Pass Prometheus metrics over stdin to lint them for consistency and correctness, and optionally perform cardinality analysis. - -examples: - -$ cat metrics.prom | promtool check metrics - -$ curl -s http://localhost:9090/metrics | promtool check metrics `--extended` - -$ curl -s http://localhost:9100/metrics | promtool check metrics `--extended` `--lint`=none - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --extended | Print extended information related to the cardinality of the metrics. | | -| --lint | Linting checks to apply for metrics. Available options are: all, none. Use --lint=none to disable metrics linting. | `all` | - - - - -### `promtool query` - -Run query against a Prometheus server. - - - -#### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| -o, --format | Output format of the query. | `promql` | -| --http.config.file | HTTP client configuration file, see details at https://prometheus.io/docs/prometheus/latest/configuration/promtool | | - - - - -##### `promtool query instant` - -Run instant query. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| --time | Query evaluation time (RFC3339 or Unix timestamp). | -| --header | Extra headers to send to server. | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to query. | Yes | -| expr | PromQL query expression. | Yes | - - - - -##### `promtool query range` - -Run range query. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| --header | Extra headers to send to server. | -| --start | Query range start time (RFC3339 or Unix timestamp). | -| --end | Query range end time (RFC3339 or Unix timestamp). | -| --step | Query step size (duration). | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to query. | Yes | -| expr | PromQL query expression. | Yes | - - - - -##### `promtool query series` - -Run series query. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| --match ... | Series selector. Can be specified multiple times. | -| --start | Start time (RFC3339 or Unix timestamp). | -| --end | End time (RFC3339 or Unix timestamp). | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to query. | Yes | - - - - -##### `promtool query labels` - -Run labels query. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| --start | Start time (RFC3339 or Unix timestamp). | -| --end | End time (RFC3339 or Unix timestamp). | -| --match ... | Series selector. Can be specified multiple times. | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to query. | Yes | -| name | Label name to provide label values for. | Yes | - - - - -##### `promtool query analyze` - -Run queries against your Prometheus to analyze the usage pattern of certain metrics. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --server | Prometheus server to query. | | -| --type | Type of metric: histogram. | | -| --duration | Time frame to analyze. | `1h` | -| --time | Query time (RFC3339 or Unix timestamp), defaults to now. | | -| --match ... | Series selector. Can be specified multiple times. | | - - - - -### `promtool debug` - -Fetch debug information. - - - -##### `promtool debug pprof` - -Fetch profiling debug information. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to get pprof files from. | Yes | - - - - -##### `promtool debug metrics` - -Fetch metrics debug information. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to get metrics from. | Yes | - - - - -##### `promtool debug all` - -Fetch all debug information. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| server | Prometheus server to get all debug information from. | Yes | - - - - -### `promtool push` - -Push to a Prometheus server. - - - -#### Flags - -| Flag | Description | -| --- | --- | -| --http.config.file | HTTP client configuration file, see details at https://prometheus.io/docs/prometheus/latest/configuration/promtool | - - - - -##### `promtool push metrics` - -Push metrics to a prometheus remote write (for testing purpose only). - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --label | Label to attach to metrics. Can be specified multiple times. | `job=promtool` | -| --timeout | The time to wait for pushing metrics. | `30s` | -| --header | Prometheus remote write header. | | -| --protobuf_message | Protobuf message to use when writing (prometheus.WriteRequest or io.prometheus.write.v2.Request). | `prometheus.WriteRequest` | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| remote-write-url | Prometheus remote write url to push metrics. | Yes | -| metric-files | The metric files to push, default is read from standard input. | | - - - - -### `promtool test` - -Unit testing. - - - -#### Flags - -| Flag | Description | -| --- | --- | -| --junit | File path to store JUnit XML test results. | - - - - -##### `promtool test rules` - -Unit tests for rules. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --run ... | If set, will only run test groups whose names match the regular expression. Can be specified multiple times. | | -| --debug | Enable unit test debugging. | `false` | -| --diff | [Experimental] Print colored differential output between expected & received output. | `false` | -| --ignore-unknown-fields | Ignore unknown fields in the test files. This is useful when you want to extend rule files with custom metadata. Ensure that those fields are removed before loading them into the Prometheus server as it performs strict checks by default. | `false` | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| test-rule-file | The unit test file. | Yes | - - - - -### `promtool tsdb` - -Run tsdb commands. - - - -##### `promtool tsdb bench` - -Run benchmarks. - - - -##### `promtool tsdb bench write` - -Run a write performance benchmark. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --out | Set the output path. | `benchout` | -| --metrics | Number of metrics to read. | `10000` | -| --scrapes | Number of scrapes to simulate. | `3000` | - - - - -###### Arguments - -| Argument | Description | Default | -| --- | --- | --- | -| file | Input file with samples data, default is (../../tsdb/testdata/20kseries.json). | `../../tsdb/testdata/20kseries.json` | - - - - -##### `promtool tsdb analyze` - -Analyze churn, label pair cardinality and compaction efficiency. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --limit | How many items to show in each list. | `20` | -| --extended | Run extended analysis. | | -| --match | Series selector to analyze. Only 1 set of matchers is supported now. | | - - - - -###### Arguments - -| Argument | Description | Default | -| --- | --- | --- | -| db path | Database path (default is data/). | `data/` | -| block id | Block to analyze (default is the last block). | | - - - - -##### `promtool tsdb list` - -List tsdb blocks. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| -r, --human-readable | Print human readable values. | - - - - -###### Arguments - -| Argument | Description | Default | -| --- | --- | --- | -| db path | Database path (default is data/). | `data/` | - - - - -##### `promtool tsdb dump` - -Dump data (series+samples or optionally just series) from a TSDB. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --sandbox-dir-root | Root directory where a sandbox directory will be created, this sandbox is used in case WAL replay generates chunks (default is the database path). The sandbox is cleaned up at the end. | | -| --min-time | Minimum timestamp to dump, in milliseconds since the Unix epoch. | `-9223372036854775808` | -| --max-time | Maximum timestamp to dump, in milliseconds since the Unix epoch. | `9223372036854775807` | -| --match ... | Series selector. Can be specified multiple times. | `{__name__=~'(?s:.*)'}` | -| --format | Output format of the dump (prom (default) or seriesjson). | `prom` | - - - - -###### Arguments - -| Argument | Description | Default | -| --- | --- | --- | -| db path | Database path (default is data/). | `data/` | - - - - -##### `promtool tsdb dump-openmetrics` - -[Experimental] Dump samples from a TSDB into OpenMetrics text format, excluding native histograms and staleness markers, which are not representable in OpenMetrics. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --sandbox-dir-root | Root directory where a sandbox directory will be created, this sandbox is used in case WAL replay generates chunks (default is the database path). The sandbox is cleaned up at the end. | | -| --min-time | Minimum timestamp to dump, in milliseconds since the Unix epoch. | `-9223372036854775808` | -| --max-time | Maximum timestamp to dump, in milliseconds since the Unix epoch. | `9223372036854775807` | -| --match ... | Series selector. Can be specified multiple times. | `{__name__=~'(?s:.*)'}` | - - - - -###### Arguments - -| Argument | Description | Default | -| --- | --- | --- | -| db path | Database path (default is data/). | `data/` | - - - - -##### `promtool tsdb create-blocks-from` - -[Experimental] Import samples from input and produce TSDB blocks. Please refer to the storage docs for more details. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| -r, --human-readable | Print human readable values. | -| -q, --quiet | Do not print created blocks. | - - - - -##### `promtool tsdb create-blocks-from openmetrics` - -Import samples from OpenMetrics input and produce TSDB blocks. Please refer to the storage docs for more details. - - - -###### Flags - -| Flag | Description | -| --- | --- | -| --label | Label to attach to metrics. Can be specified multiple times. Example --label=label_name=label_value | - - - - -###### Arguments - -| Argument | Description | Default | Required | -| --- | --- | --- | --- | -| input file | OpenMetrics file to read samples from. | | Yes | -| output directory | Output directory for generated blocks. | `data/` | | - - - - -##### `promtool tsdb create-blocks-from rules` - -Create blocks of data for new recording rules. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| --http.config.file | HTTP client configuration file, see details at https://prometheus.io/docs/prometheus/latest/configuration/promtool | | -| --url | The URL for the Prometheus API with the data where the rule will be backfilled from. | `http://localhost:9090` | -| --start | The time to start backfilling the new rule from. Must be a RFC3339 formatted date or Unix timestamp. Required. | | -| --end | If an end time is provided, all recording rules in the rule files provided will be backfilled to the end time. Default will backfill up to 3 hours ago. Must be a RFC3339 formatted date or Unix timestamp. | | -| --output-dir | Output directory for generated blocks. | `data/` | -| --eval-interval | How frequently to evaluate rules when backfilling if a value is not set in the recording rule files. | `60s` | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| rule-files | A list of one or more files containing recording rules to be backfilled. All recording rules listed in the files will be backfilled. Alerting rules are not evaluated. | Yes | - - - - -### `promtool promql` - -PromQL formatting and editing. Requires the `--experimental` flag. - - - -##### `promtool promql format` - -Format PromQL query to pretty printed form. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| query | PromQL query. | Yes | - - - - -##### `promtool promql label-matchers` - -Edit label matchers contained within an existing PromQL query. - - - -##### `promtool promql label-matchers set` - -Set a label matcher in the query. - - - -###### Flags - -| Flag | Description | Default | -| --- | --- | --- | -| -t, --type | Type of the label matcher to set. | `=` | - - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| query | PromQL query. | Yes | -| name | Name of the label matcher to set. | Yes | -| value | Value of the label matcher to set. | Yes | - - - - -##### `promtool promql label-matchers delete` - -Delete a label from the query. - - - -###### Arguments - -| Argument | Description | Required | -| --- | --- | --- | -| query | PromQL query. | Yes | -| name | Name of the label to delete. | Yes | - - diff --git a/docs/configuration/alerting_rules.md b/docs/configuration/alerting_rules.md deleted file mode 100644 index faffad56f2..0000000000 --- a/docs/configuration/alerting_rules.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -title: Alerting rules -sort_rank: 3 ---- - -Alerting rules allow you to define alert conditions based on Prometheus -expression language expressions and to send notifications about firing alerts -to an external service. Whenever the alert expression results in one or more -vector elements at a given point in time, the alert counts as active for these -elements' label sets. - -## Defining alerting rules - -Alerting rules are configured in Prometheus in the same way as [recording -rules](recording_rules.md). - -An example rules file with an alert would be: - -```yaml -groups: -- name: example - labels: - team: myteam - rules: - - alert: HighRequestLatency - expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5 - for: 10m - keep_firing_for: 5m - labels: - severity: page - annotations: - summary: High request latency -``` - -The optional `for` clause causes Prometheus to wait for a certain duration -between first encountering a new expression output vector element and counting -an alert as firing for this element. In this case, Prometheus will check that -the alert continues to be active during each evaluation for 10 minutes before -firing the alert. Elements that are active, but not firing yet, are in the pending state. -Alerting rules without the `for` clause will become active on the first evaluation. - -There is also an optional `keep_firing_for` clause that tells Prometheus to keep -this alert firing for the specified duration after the firing condition was last met. -This can be used to prevent situations such as flapping alerts, false resolutions -due to lack of data loss, etc. Alerting rules without the `keep_firing_for` clause -will deactivate on the first evaluation where the condition is not met (assuming -any optional `for` duration described above has been satisfied). - -The `labels` clause allows specifying a set of additional labels to be attached -to the alert. Any existing conflicting labels will be overwritten. The label -values can be templated. - -The `annotations` clause specifies a set of informational labels that can be used to store longer additional information such as alert descriptions or runbook links. The annotation values can be templated. - -### Templating - -Label and annotation values can be templated using [console -templates](https://prometheus.io/docs/visualization/consoles). The `$labels` -variable holds the label key/value pairs of an alert instance. The configured -external labels can be accessed via the `$externalLabels` variable. The -`$value` variable holds the evaluated value of an alert instance. - - # To insert a firing element's label values: - {{ $labels. }} - # To insert the numeric expression value of the firing element: - {{ $value }} - -Examples: - -```yaml -groups: -- name: example - rules: - - # Alert for any instance that is unreachable for >5 minutes. - - alert: InstanceDown - expr: up == 0 - for: 5m - labels: - severity: page - annotations: - summary: "Instance {{ $labels.instance }} down" - description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes." - - # Alert for any instance that has a median request latency >1s. - - alert: APIHighRequestLatency - expr: api_http_request_latencies_second{quantile="0.5"} > 1 - for: 10m - annotations: - summary: "High request latency on {{ $labels.instance }}" - description: "{{ $labels.instance }} has a median request latency above 1s (current value: {{ $value }}s)" -``` - -## Inspecting alerts during runtime - -To manually inspect which alerts are active (pending or firing), navigate to -the "Alerts" tab of your Prometheus instance. This will show you the exact -label sets for which each defined alert is currently active. - -For pending and firing alerts, Prometheus also stores synthetic time series of -the form `ALERTS{alertname="", alertstate="", }`. -The sample value is set to `1` as long as the alert is in the indicated active -(pending or firing) state, and the series is marked stale when this is no -longer the case. - -## Sending alert notifications - -Prometheus's alerting rules are good at figuring what is broken *right now*, but -they are not a fully-fledged notification solution. Another layer is needed to -add summarization, notification rate limiting, silencing and alert dependencies -on top of the simple alert definitions. In Prometheus's ecosystem, the -[Alertmanager](https://prometheus.io/docs/alerting/alertmanager/) takes on this -role. Thus, Prometheus may be configured to periodically send information about -alert states to an Alertmanager instance, which then takes care of dispatching -the right notifications. -Prometheus can be [configured](configuration.md) to automatically discover available -Alertmanager instances through its service discovery integrations. diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md deleted file mode 100644 index 19a1bdbca5..0000000000 --- a/docs/configuration/configuration.md +++ /dev/null @@ -1,4100 +0,0 @@ ---- -title: Configuration -sort_rank: 1 ---- - -Prometheus is configured via command-line flags and a configuration file. While -the command-line flags configure immutable system parameters (such as storage -locations, amount of data to keep on disk and in memory, etc.), the -configuration file defines everything related to scraping [jobs and their -instances](https://prometheus.io/docs/concepts/jobs_instances/), as well as -which [rule files to load](recording_rules.md#configuring-rules). - -To view all available command-line flags, run `./prometheus -h`. - -Prometheus can reload its configuration at runtime. If the new configuration -is not well-formed, the changes will not be applied. -A configuration reload is triggered by sending a `SIGHUP` to the Prometheus process or -sending a HTTP POST request to the `/-/reload` endpoint (when the `--web.enable-lifecycle` flag is enabled). -This will also reload any configured rule files. - -## Configuration file - -To specify which configuration file to load, use the `--config.file` flag. - -The file is written in [YAML format](https://en.wikipedia.org/wiki/YAML), -defined by the scheme described below. -Brackets indicate that a parameter is optional. For non-list parameters the -value is set to the specified default. - -Generic placeholders are defined as follows: - -* ``: a boolean that can take the values `true` or `false` -* ``: a duration matching the regular expression `((([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?|0)`, e.g. `1d`, `1h30m`, `5m`, `10s` -* ``: a valid path in the current working directory -* ``: a floating-point number -* ``: a valid string consisting of a hostname or IP followed by an optional port number -* ``: an integer value -* ``: a string matching the regular expression `[a-zA-Z_][a-zA-Z0-9_]*`. Any other unsupported character in the source label should be converted to an underscore. For example, the label `app.kubernetes.io/name` should be written as `app_kubernetes_io_name`. -* ``: a string of unicode characters -* ``: a valid URL path -* ``: a string that can take the values `http` or `https` -* ``: a regular string that is a secret, such as a password -* ``: a regular string -* ``: a size in bytes, e.g. `512MB`. A unit is required. Supported units: B, KB, MB, GB, TB, PB, EB. -* ``: a string which is template-expanded before usage - -The other placeholders are specified separately. - -A valid example file can be found [here](/config/testdata/conf.good.yml). - -The global configuration specifies parameters that are valid in all other configuration -contexts. They also serve as defaults for other configuration sections. - -```yaml -global: - # How frequently to scrape targets by default. - [ scrape_interval: | default = 1m ] - - # How long until a scrape request times out. - # It cannot be greater than the scrape interval. - [ scrape_timeout: | default = 10s ] - - # The protocols to negotiate during a scrape with the client. - # Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1, - # OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0. - # If left unset both here and in an individual scrape config, the - # negotiation order used in that scrape config depends on the effective - # value of scrape_native_histograms for that scrape config. - # If scrape_native_histograms is false, the order is - # [ OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ]. - # If scrape_native_histograms is true, the order is - # [ PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ]. - [ scrape_protocols: [, ...] ] - - # How frequently to evaluate rules. - [ evaluation_interval: | default = 1m ] - - # Offset the rule evaluation timestamp of this particular group by the - # specified duration into the past to ensure the underlying metrics have - # been received. Metric availability delays are more likely to occur when - # Prometheus is running as a remote write target, but can also occur when - # there's anomalies with scraping. - [ rule_query_offset: | default = 0s ] - - # The labels to add to any time series or alerts when communicating with - # external systems (federation, remote storage, Alertmanager). - # Environment variable references `${var}` or `$var` are replaced according - # to the values of the current environment variables. - # References to undefined variables are replaced by the empty string. - # The `$` character can be escaped by using `$$`. - external_labels: - [ : ... ] - - # File to which PromQL queries are logged. - # Reloading the configuration will reopen the file. - [ query_log_file: ] - - # File to which scrape failures are logged. - # Reloading the configuration will reopen the file. - [ scrape_failure_log_file: ] - - # An uncompressed response body larger than this many bytes will cause the - # scrape to fail. 0 means no limit. Example: 100MB. - # This is an experimental feature, this behaviour could - # change or be removed in the future. - [ body_size_limit: | default = 0 ] - - # Per-scrape limit on the number of scraped samples that will be accepted. - # If more than this number of samples are present after metric relabeling - # the entire scrape will be treated as failed. 0 means no limit. - [ sample_limit: | default = 0 ] - - # Limit on the number of labels that will be accepted per sample. If more - # than this number of labels are present on any sample post metric-relabeling, - # the entire scrape will be treated as failed. 0 means no limit. - [ label_limit: | default = 0 ] - - # Limit on the length (in bytes) of each individual label name. If any label - # name in a scrape is longer than this number post metric-relabeling, the - # entire scrape will be treated as failed. Note that label names are UTF-8 - # encoded, and characters can take up to 4 bytes. 0 means no limit. - [ label_name_length_limit: | default = 0 ] - - # Limit on the length (in bytes) of each individual label value. If any label - # value in a scrape is longer than this number post metric-relabeling, the - # entire scrape will be treated as failed. Note that label values are UTF-8 - # encoded, and characters can take up to 4 bytes. 0 means no limit. - [ label_value_length_limit: | default = 0 ] - - # Limit per scrape config on number of unique targets that will be - # accepted. If more than this number of targets are present after target - # relabeling, Prometheus will mark the targets as failed without scraping them. - # 0 means no limit. This is an experimental feature, this behaviour could - # change in the future. - [ target_limit: | default = 0 ] - - # Limit per scrape config on the number of targets dropped by relabeling - # that will be kept in memory. 0 means no limit. - [ keep_dropped_targets: | default = 0 ] - - # Specifies the validation scheme for metric and label names. Either blank or - # "utf8" for full UTF-8 support, or "legacy" for letters, numbers, colons, - # and underscores. - [ metric_name_validation_scheme: | default "utf8" ] - - # If true, native histograms exposed by a target are recognized during - # scraping and ingested as such. If false, any native parts of histograms - # are ignored and only the classic parts are recognized (possibly as - # a classic histogram with only the +Inf buckets if no explicit classic - # buckets are part of the histogram). - [ scrape_native_histograms: | default = false ] - - # Specifies whether to convert scraped classic histograms into native - # histograms with custom buckets. - [ convert_classic_histograms_to_nhcb: | default = false ] - - # Specifies whether to additionally scrape the classic parts of a histogram, - # even if it is also exposed with native parts or it is converted into a - # native histogram with custom buckets. - [ always_scrape_classic_histograms: | default = false ] - - # When enabled, Prometheus stores additional time series for each scrape: - # scrape_timeout_seconds, scrape_sample_limit, and scrape_body_size_bytes. - # These metrics help monitor how close targets are to their configured limits. - # This option can be overridden per scrape config. - [ extra_scrape_metrics: | default = false ] - - # The following explains the various combinations of the last three options - # in various exposition cases. - # - # CASE 1: A histogram is solely exposed as a classic histogram. (Note that - # this also applies if the used scrape protocol (also see the - # scrape_protocols setting) does not support native histograms.) In this - # case, the scrape_native_histograms setting has no effect. If - # convert_classic_histograms_to_nhcb is false, the histogram is ingested as - # a classic histograms. If convert_classic_histograms_to_nhcb is true, the - # histograms is converted to an NHCB. In this case, - # always_scrape_classic_histograms determines whether it is also ingested - # as a classic histograms or not. - # - # CASE 2: A histogram is solely exposed as a native histogram, i.e. it has - # no classic buckets except the optional +Inf bucket but it is marked as a - # native histogram (by some "native parts", at the very least by a no-op - # span). If scrape_native_histograms is false, this case is handled like case - # 1, but the resulting classic histogram or NHCB only has a sole bucket, the - # +Inf bucket. If scrape_native_histograms is true, however, the histogram is - # recognized as a pure native histogram and ingested as such. There will be - # no classic histogram ingested, no matter what - # always_scrape_classic_histograms is set to, and there will be no - # conversion to an NHCB, no matter what convert_classic_histograms_to_nhcb - # is set to. - # - # CASE 3: A histogram is exposed as both a native and a classic histogram, - # i.e. it has "native parts" (at the very least a no-op span) and it has at - # least one classic bucket that is not the +Inf bucket. If - # scrape_native_histograms is false, this case is handled like case 1. The - # native parts are ignored, and there will be either a classic histogram, an - # NHCB, or both. If scrape_native_histograms is true, the histogram is - # ingested as a native histogram. There will be no NHCB, no matter what - # convert_classic_histograms_to_nhcb is set to (it would collide with the - # actual native histogram). However, there will be a classic histogram if (and - # only if) always_scrape_classic_histograms is set to true. - -runtime: - # Configure the Go garbage collector GOGC parameter - # See: https://tip.golang.org/doc/gc-guide#GOGC - # Lowering this number increases CPU usage. - [ gogc: | default = 75 ] - -# Rule files specifies a list of globs. Rules and alerts are read from -# all matching files. -rule_files: - [ - ... ] - -# Scrape config files specifies a list of globs. Scrape configs are read from -# all matching files and appended to the list of scrape configs. -scrape_config_files: - [ - ... ] - -# A list of scrape configurations. -scrape_configs: - [ - ... ] - -# Alerting specifies settings related to the Alertmanager. -alerting: - alert_relabel_configs: - [ - ... ] - alertmanagers: - [ - ... ] - -# Settings related to the remote write feature. -remote_write: - [ - ... ] - -# Settings related to the OTLP receiver feature. -# See https://prometheus.io/docs/guides/opentelemetry/ for best practices. -otlp: - # Promote specific list of resource attributes to labels. - # It cannot be configured simultaneously with 'promote_all_resource_attributes: true'. - [ promote_resource_attributes: [, ...] | default = [ ] ] - # Promoting all resource attributes to labels, except for the ones configured with 'ignore_resource_attributes'. - # Be aware that changes in attributes received by the OTLP endpoint may result in time series churn and lead to high memory usage by the Prometheus server. - # It cannot be set to 'true' simultaneously with 'promote_resource_attributes'. - [ promote_all_resource_attributes: | default = false ] - # Which resource attributes to ignore, can only be set when 'promote_all_resource_attributes' is true. - [ ignore_resource_attributes: [, ...] | default = [] ] - # Configures translation of OTLP metrics when received through the OTLP metrics - # endpoint. Available values: - # - "UnderscoreEscapingWithSuffixes" refers to commonly agreed normalization used - # by OpenTelemetry in https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/translator/prometheus - # - "NoUTF8EscapingWithSuffixes" is a mode that relies on UTF-8 support in Prometheus. - # It preserves all special characters like dots, but still adds required metric name suffixes - # for units and _total, as UnderscoreEscapingWithSuffixes does. - # - "UnderscoreEscapingWithoutSuffixes" translates metric name characters that - # are not alphanumerics/underscores/colons to underscores, and label name - # characters that are not alphanumerics/underscores to underscores, but - # unlike UnderscoreEscapingWithSuffixes it does not append any suffixes to - # the names. - # - (EXPERIMENTAL) "NoTranslation" is a mode that relies on UTF-8 support in Prometheus. - # It preserves all special character like dots and won't append special suffixes for metric - # unit and type. - # - # WARNING: The "NoTranslation" setting has significant known risks and limitations (see https://prometheus.io/docs/practices/naming/ - # for details): - # * Impaired UX when using PromQL in plain YAML (e.g. alerts, rules, dashboard, autoscaling configuration). - # * Series collisions which in the best case may result in OOO errors, in the worst case a silently malformed - # time series. For instance, you may end up in situation of ingesting `foo.bar` series with unit - # `seconds` and a separate series `foo.bar` with unit `milliseconds`. - [ translation_strategy: | default = "UnderscoreEscapingWithSuffixes" ] - # Enables adding "service.name", "service.namespace" and "service.instance.id" - # resource attributes to the "target_info" metric, on top of converting - # them into the "instance" and "job" labels. - [ keep_identifying_resource_attributes: | default = false ] - # Configures optional translation of OTLP explicit bucket histograms into native histograms with custom buckets. - [ convert_histograms_to_nhcb: | default = false ] - # Enables promotion of OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels. - # This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels. - [ promote_scope_metadata: | default = false ] - # Controls whether to enable prepending of 'key_' to labels starting with '_'. - # Reserved labels starting with '__' are not modified. - # This is only relevant when translation_strategy uses underscore escaping - # (e.g., "UnderscoreEscapingWithSuffixes" or "UnderscoreEscapingWithoutSuffixes"). - [ label_name_underscore_sanitization: | default = true ] - # Enables preserving of multiple consecutive underscores in label names when - # translation_strategy uses underscore escaping. When true (default), multiple - # consecutive underscores are preserved during label name sanitization. - [ label_name_preserve_multiple_underscores: | default = true ] - -# Settings related to the remote read feature. -remote_read: - [ - ... ] - -# Storage related settings that are runtime reloadable. -storage: - [ tsdb: ] - [ exemplars: ] - -# Configures exporting traces. -tracing: - [ ] -``` - -### `` - -A `scrape_config` section specifies a set of targets and parameters describing how -to scrape them. In the general case, one scrape configuration specifies a single -job. In advanced configurations, this may change. - -Targets may be statically configured via the `static_configs` parameter or -dynamically discovered using one of the supported service-discovery mechanisms. - -Additionally, `relabel_configs` allow advanced modifications to any -target and its labels before scraping. - -```yaml -# The job name assigned to scraped metrics by default. -job_name: - -# How frequently to scrape targets from this job. -[ scrape_interval: | default = ] - -# Per-scrape timeout when scraping this job. -# It cannot be greater than the scrape interval. -[ scrape_timeout: | default = ] - -# The protocols to negotiate during a scrape with the client. -# Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1, -# OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0. -# If not set in the global config, the default value depends on the -# setting of scrape_native_histograms. If false, it is -# [ OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ]. -# If true, it is -# [ PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText1.0.0, PrometheusText0.0.4 ]. -[ scrape_protocols: [, ...] | default = ] - -# Fallback protocol to use if a scrape returns blank, unparsable, or otherwise -# invalid Content-Type. -# Supported values (case sensitive): PrometheusProto, OpenMetricsText0.0.1, -# OpenMetricsText1.0.0, PrometheusText0.0.4, PrometheusText1.0.0. -[ fallback_scrape_protocol: ] - -# The HTTP resource path on which to fetch metrics from targets. -[ metrics_path: | default = /metrics ] - -# honor_labels controls how Prometheus handles conflicts between labels that are -# already present in scraped data and labels that Prometheus would attach -# server-side ("job" and "instance" labels, manually configured target -# labels, and labels generated by service discovery implementations). -# -# If honor_labels is set to "true", label conflicts are resolved by keeping label -# values from the scraped data and ignoring the conflicting server-side labels. -# -# If honor_labels is set to "false", label conflicts are resolved by renaming -# conflicting labels in the scraped data to "exported_" (for -# example "exported_instance", "exported_job") and then attaching server-side -# labels. -# -# Setting honor_labels to "true" is useful for use cases such as federation and -# scraping the Pushgateway, where all labels specified in the target should be -# preserved. -# -# Note that any globally configured "external_labels" are unaffected by this -# setting. In communication with external systems, they are always applied only -# when a time series does not have a given label yet and are ignored otherwise. -[ honor_labels: | default = false ] - -# honor_timestamps controls whether Prometheus respects the timestamps present -# in scraped data. -# -# If honor_timestamps is set to "true", the timestamps of the metrics exposed -# by the target will be used. -# -# If honor_timestamps is set to "false", the timestamps of the metrics exposed -# by the target will be ignored. -[ honor_timestamps: | default = true ] - -# track_timestamps_staleness controls whether Prometheus tracks staleness of -# the metrics that have an explicit timestamps present in scraped data. -# -# If track_timestamps_staleness is set to "true", a staleness marker will be -# inserted in the TSDB when a metric is no longer present or the target -# is down. -[ track_timestamps_staleness: | default = false ] - -# Configures the protocol scheme used for requests. -[ scheme: | default = http ] - -# Optional HTTP URL parameters. -params: - [ : [, ...] ] - -# If enable_compression is set to "false", Prometheus will request uncompressed -# response from the scraped target. -[ enable_compression: | default = true ] - -# File to which scrape failures are logged. -# Reloading the configuration will reopen the file. -[ scrape_failure_log_file: ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] - -# List of AWS service discovery configurations. -aws_sd_configs: - [ - ... ] - -# List of Azure service discovery configurations. -azure_sd_configs: - [ - ... ] - -# List of Consul service discovery configurations. -consul_sd_configs: - [ - ... ] - -# List of DigitalOcean service discovery configurations. -digitalocean_sd_configs: - [ - ... ] - -# List of Docker service discovery configurations. -docker_sd_configs: - [ - ... ] - -# List of Docker Swarm service discovery configurations. -dockerswarm_sd_configs: - [ - ... ] - -# List of DNS service discovery configurations. -dns_sd_configs: - [ - ... ] - -# List of EC2 service discovery configurations. -ec2_sd_configs: - [ - ... ] - -# List of Eureka service discovery configurations. -eureka_sd_configs: - [ - ... ] - -# List of file service discovery configurations. -file_sd_configs: - [ - ... ] - -# List of GCE service discovery configurations. -gce_sd_configs: - [ - ... ] - -# List of Hetzner service discovery configurations. -hetzner_sd_configs: - [ - ... ] - -# List of HTTP service discovery configurations. -http_sd_configs: - [ - ... ] - - -# List of IONOS service discovery configurations. -ionos_sd_configs: - [ - ... ] - -# List of Kubernetes service discovery configurations. -kubernetes_sd_configs: - [ - ... ] - -# List of Kuma service discovery configurations. -kuma_sd_configs: - [ - ... ] - -# List of Lightsail service discovery configurations. -lightsail_sd_configs: - [ - ... ] - -# List of Linode service discovery configurations. -linode_sd_configs: - [ - ... ] - -# List of Marathon service discovery configurations. -marathon_sd_configs: - [ - ... ] - -# List of AirBnB's Nerve service discovery configurations. -nerve_sd_configs: - [ - ... ] - -# List of Nomad service discovery configurations. -nomad_sd_configs: - [ - ... ] - -# List of OpenStack service discovery configurations. -openstack_sd_configs: - [ - ... ] - -# List of Outscale service discovery configurations. -outscale_sd_configs: - [ - ... ] - -# List of OVHcloud service discovery configurations. -ovhcloud_sd_configs: - [ - ... ] - -# List of PuppetDB service discovery configurations. -puppetdb_sd_configs: - [ - ... ] - -# List of Scaleway service discovery configurations. -scaleway_sd_configs: - [ - ... ] - -# List of Zookeeper Serverset service discovery configurations. -serverset_sd_configs: - [ - ... ] - -# List of STACKIT service discovery configurations. -stackit_sd_configs: - [ - ... ] - -# List of Triton service discovery configurations. -triton_sd_configs: - [ - ... ] - -# List of Uyuni service discovery configurations. -uyuni_sd_configs: - [ - ... ] - -# List of labeled statically configured targets for this job. -static_configs: - [ - ... ] - -# List of target relabel configurations. -relabel_configs: - [ - ... ] - -# List of metric relabel configurations. -metric_relabel_configs: - [ - ... ] - -# An uncompressed response body larger than this many bytes will cause the -# scrape to fail. 0 means no limit. Example: 100MB. -# This is an experimental feature, this behaviour could -# change or be removed in the future. -[ body_size_limit: | default = 0 ] - -# Per-scrape limit on the number of scraped samples that will be accepted. -# If more than this number of samples are present after metric relabeling -# the entire scrape will be treated as failed. 0 means no limit. -[ sample_limit: | default = 0 ] - -# Limit on the number of labels that will be accepted per sample. If more -# than this number of labels are present on any sample post metric-relabeling, -# the entire scrape will be treated as failed. 0 means no limit. -[ label_limit: | default = 0 ] - -# Limit on the length (in bytes) of each individual label name. If any label -# name in a scrape is longer than this number post metric-relabeling, the -# entire scrape will be treated as failed. Note that label names are UTF-8 -# encoded, and characters can take up to 4 bytes. 0 means no limit. -[ label_name_length_limit: | default = 0 ] - -# Limit on the length (in bytes) of each individual label value. If any label -# value in a scrape is longer than this number post metric-relabeling, the -# entire scrape will be treated as failed. Note that label values are UTF-8 -# encoded, and characters can take up to 4 bytes. 0 means no limit. -[ label_value_length_limit: | default = 0 ] - -# Limit per scrape config on number of unique targets that will be -# accepted. If more than this number of targets are present after target -# relabeling, Prometheus will mark the targets as failed without scraping them. -# 0 means no limit. This is an experimental feature, this behaviour could -# change in the future. -[ target_limit: | default = 0 ] - -# Limit per scrape config on the number of targets dropped by relabeling -# that will be kept in memory. 0 means no limit. -[ keep_dropped_targets: | default = 0 ] - -# Specifies the validation scheme for metric and label names. Either blank or -# "utf8" for full UTF-8 support, or "legacy" for letters, numbers, colons, and -# underscores. -[ metric_name_validation_scheme: | default "utf8" ] - -# Specifies the character escaping scheme that will be requested when scraping -# for metric and label names that do not conform to the legacy Prometheus -# character set. Available options are: -# * `allow-utf-8`: Full UTF-8 support, no escaping needed. -# * `underscores`: Escape all legacy-invalid characters to underscores. -# * `dots`: Escapes dots to `_dot_`, underscores to `__`, and all other -# legacy-invalid characters to underscores. -# * `values`: Prepend the name with `U__` and replace all invalid -# characters with their unicode value, surrounded by underscores. Single -# underscores are replaced with double underscores. -# e.g. "U__my_2e_dotted_2e_name". -# If this value is left blank, Prometheus will default to `allow-utf-8` if the -# validation scheme for the current scrape config is set to utf8, or -# `underscores` if the validation scheme is set to `legacy`. -[ metric_name_escaping_scheme: | default "allow-utf-8" ] - -# Limit on total number of positive and negative buckets allowed in a single -# native histogram. The resolution of a histogram with more buckets will be -# reduced until the number of buckets is within the limit. If the limit cannot -# be reached, the scrape will fail. -# 0 means no limit. -[ native_histogram_bucket_limit: | default = 0 ] - -# Lower limit for the growth factor of one bucket to the next in each native -# histogram. The resolution of a histogram with a lower growth factor will be -# reduced as much as possible until it is within the limit. -# To set an upper limit for the schema (equivalent to "scale" in OTel's -# exponential histograms), use the following factor limits: -# -# +----------------------------+----------------------------+ -# | growth factor | resulting schema AKA scale | -# +----------------------------+----------------------------+ -# | 65536 | -4 | -# +----------------------------+----------------------------+ -# | 256 | -3 | -# +----------------------------+----------------------------+ -# | 16 | -2 | -# +----------------------------+----------------------------+ -# | 4 | -1 | -# +----------------------------+----------------------------+ -# | 2 | 0 | -# +----------------------------+----------------------------+ -# | 1.4 | 1 | -# +----------------------------+----------------------------+ -# | 1.1 | 2 | -# +----------------------------+----------------------------+ -# | 1.09 | 3 | -# +----------------------------+----------------------------+ -# | 1.04 | 4 | -# +----------------------------+----------------------------+ -# | 1.02 | 5 | -# +----------------------------+----------------------------+ -# | 1.01 | 6 | -# +----------------------------+----------------------------+ -# | 1.005 | 7 | -# +----------------------------+----------------------------+ -# | 1.002 | 8 | -# +----------------------------+----------------------------+ -# -# 0 results in the smallest supported factor (which is currently ~1.0027 or -# schema 8, but might change in the future). -[ native_histogram_min_bucket_factor: | default = 0 ] - -# If true, native histograms exposed by a target are recognized during -# scraping and ingested as such. If false, any native parts of histograms -# are ignored and only the classic parts are recognized (possibly as -# a classic histogram with only the +Inf buckets if no explicit classic -# buckets are part of the histogram). -[ scrape_native_histograms: | default = ] - -# Specifies whether to convert classic histograms into native histograms with -# custom buckets. -[ convert_classic_histograms_to_nhcb: | default = ] - -# Specifies whether to additionally scrape the classic parts of a histogram, -# even if it is also exposed with native parts or it is converted into a -# native histogram with custom buckets. -[ always_scrape_classic_histograms: | default = ] - -# When enabled, Prometheus stores additional time series for this scrape job: -# scrape_timeout_seconds, scrape_sample_limit, and scrape_body_size_bytes. -# These metrics help monitor how close targets are to their configured limits. -# If not set, inherits the value from the global configuration. -[ extra_scrape_metrics: | default = ] - -# See global configuration above for further explanations of how the last three -# options combine their effects. - -``` - -Where `` must be unique across all scrape configurations. - -### `` - -A `http_config` allows configuring HTTP requests. - -```yaml -# Sets the `Authorization` header on every request with the -# configured username and password. -# username and username_file are mutually exclusive. -# password and password_file are mutually exclusive. -basic_auth: - [ username: ] - [ username_file: ] - [ password: ] - [ password_file: ] - -# Sets the `Authorization` header on every request with -# the configured credentials. -authorization: - # Sets the authentication type of the request. - [ type: | default: Bearer ] - # Sets the credentials of the request. It is mutually exclusive with - # `credentials_file`. - [ credentials: ] - # Sets the credentials of the request with the credentials read from the - # configured file. It is mutually exclusive with `credentials`. - [ credentials_file: ] - -# Optional OAuth 2.0 configuration. -# Cannot be used at the same time as basic_auth or authorization. -oauth2: - [ ] - -# Configure whether requests follow HTTP 3xx redirects. -[ follow_redirects: | default = true ] - -# Whether to enable HTTP2. -[ enable_http2: | default: true ] - -# Configures the request's TLS settings. -tls_config: - [ ] - -# Optional proxy URL. -[ proxy_url: ] -# Comma-separated string that can contain IPs, CIDR notation, domain names -# that should be excluded from proxying. IP and domain names can -# contain port numbers. -[ no_proxy: ] -# Use proxy URL indicated by environment variables (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy) -[ proxy_from_environment: | default: false ] -# Specifies headers to send to proxies during CONNECT requests. -[ proxy_connect_header: - [ : [, ...] ] ] - -# Custom HTTP headers to be sent along with each request. -# Headers that are set by Prometheus itself can't be overwritten. -http_headers: - # Header name. - [ : - # Header values. - [ values: [, ...] ] - # Headers values. Hidden in configuration page. - [ secrets: [, ...] ] - # Files to read header values from. - [ files: [, ...] ] ] -``` - -### `` - -A `tls_config` allows configuring TLS connections. - -```yaml -# CA certificate to validate API server certificate with. At most one of ca and ca_file is allowed. -[ ca: ] -[ ca_file: ] - -# Certificate and key for client cert authentication to the server. -# At most one of cert and cert_file is allowed. -# At most one of key and key_file is allowed. -[ cert: ] -[ cert_file: ] -[ key: ] -[ key_file: ] - -# ServerName extension to indicate the name of the server. -# https://tools.ietf.org/html/rfc4366#section-3.1 -[ server_name: ] - -# Disable validation of the server certificate. -[ insecure_skip_verify: ] - -# Minimum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS -# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3). -# If unset, Prometheus will use Go default minimum version, which is TLS 1.2. -# See MinVersion in https://pkg.go.dev/crypto/tls#Config. -[ min_version: ] -# Maximum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS -# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3). -# If unset, Prometheus will use Go default maximum version, which is TLS 1.3. -# See MaxVersion in https://pkg.go.dev/crypto/tls#Config. -[ max_version: ] -``` - -### `` - -OAuth 2.0 authentication using the client credentials or password grant type. -Prometheus fetches an access token from the specified endpoint with -the given client access and credentials. - -```yaml -client_id: - -# OAuth2 grant type to use. It can be one of -# "client_credentials" or "urn:ietf:params:oauth:grant-type:jwt-bearer" (RFC 7523). -# Default value is "client_credentials" -[ grant_type: ] - -# Client secret to provide to authorization server. Only used if -# GrantType is set empty or set to "client_credentials". -[ client_secret: ] - -# Read the client secret from a file. -# It is mutually exclusive with `client_secret`. -[ client_secret_file: ] - -# Secret key to sign JWT with. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -[ client_certificate_key: ] - -# Read the secret key from a file. -# It is mutually exclusive with `client_certificate_key`. -[ client_certificate_key_file: ] - -# JWT kid value to include in the JWT header. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -[ client_certificate_key_id: ] - -# Signature algorithm used to sign JWT token. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -# Default value is RS256 and valid values RS256, RS384, RS512 -[ signature_algorithm: ] - -# OAuth client identifier used when communicating with -# the configured OAuth provider. Default value is client_id. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -[ iss: ] - -# Intended audience of the request. If empty, the value -# of TokenURL is used as the intended audience. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -[ audience: ] - -# Map of claims to be added to the JWT token. Only used if -# GrantType is set to "urn:ietf:params:oauth:grant-type:jwt-bearer". -claims: - [ : ... ] - -# Scopes for the token request. -scopes: - [ - ... ] - -# The URL to fetch the token from. -token_url: - -# Optional parameters to append to the token URL. -# To set 'password' grant type, add it to params: -# endpoint_params: -# grant_type: 'password' -# username: 'username@example.com' -# password: 'strongpassword' -endpoint_params: - [ : ... ] - -# Configures the token request's TLS settings. -tls_config: - [ ] - -# Optional proxy URL. -[ proxy_url: ] -# Comma-separated string that can contain IPs, CIDR notation, domain names -# that should be excluded from proxying. IP and domain names can -# contain port numbers. -[ no_proxy: ] -# Use proxy URL indicated by environment variables (HTTP_PROXY, https_proxy, HTTPs_PROXY, https_proxy, and no_proxy) -[ proxy_from_environment: | default: false ] -# Specifies headers to send to proxies during CONNECT requests. -[ proxy_connect_header: - [ : [, ...] ] ] - -# Custom HTTP headers to be sent along with each request. -# Headers that are set by Prometheus itself can't be overwritten. -http_headers: - # Header name. - [ : - # Header values. - [ values: [, ...] ] - # Headers values. Hidden in configuration page. - [ secrets: [, ...] ] - # Files to read header values from. - [ files: [, ...] ] ] -``` - -### `` - -AWS SD configurations allow retrieving scrape targets from AWS services. -This is a unified service discovery that supports multiple AWS service types through the `role` parameter. - -One of the following `role` types can be configured to discover targets: - -#### `ec2` - -The `ec2` role discovers targets from AWS EC2 instances. The private IP address is used by default, but may be changed to -the public IP address with relabeling. - -The IAM credentials used must have the `ec2:DescribeInstances` permission to -discover scrape targets, and may optionally have the -`ec2:DescribeAvailabilityZones` permission if you want the availability zone ID -available as a label (see below). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_ec2_ami`: the EC2 Amazon Machine Image -* `__meta_ec2_architecture`: the architecture of the instance -* `__meta_ec2_availability_zone`: the availability zone in which the instance is running -* `__meta_ec2_availability_zone_id`: the [availability zone ID](https://docs.aws.amazon.com/ram/latest/userguide/working-with-az-ids.html) in which the instance is running (requires `ec2:DescribeAvailabilityZones`) -* `__meta_ec2_instance_id`: the EC2 instance ID -* `__meta_ec2_instance_lifecycle`: the lifecycle of the EC2 instance, set only for 'spot' or 'scheduled' instances, absent otherwise -* `__meta_ec2_instance_state`: the state of the EC2 instance -* `__meta_ec2_instance_type`: the type of the EC2 instance -* `__meta_ec2_ipv6_addresses`: comma separated list of IPv6 addresses assigned to the instance's network interfaces, if present -* `__meta_ec2_owner_id`: the ID of the AWS account that owns the EC2 instance -* `__meta_ec2_platform`: the Operating System platform, set to 'windows' on Windows servers, absent otherwise -* `__meta_ec2_default_ipv6_address`: the first primary IPv6 address found if present, otherwise first non-primary IPv6 address, if present -* `__meta_ec2_primary_ipv6_addresses`: comma separated list of the Primary IPv6 addresses of the instance, if present. The list is ordered based on the position of each corresponding network interface in the attachment order. -* `__meta_ec2_primary_subnet_id`: the subnet ID of the primary network interface, if available -* `__meta_ec2_private_dns_name`: the private DNS name of the instance, if available -* `__meta_ec2_private_ip`: the private IP address of the instance, if present -* `__meta_ec2_public_dns_name`: the public DNS name of the instance, if available -* `__meta_ec2_public_ip`: the public IP address of the instance, if available -* `__meta_ec2_region`: the region of the instance -* `__meta_ec2_subnet_id`: comma separated list of subnets IDs in which the instance is running, if available -* `__meta_ec2_tag_`: each tag value of the instance -* `__meta_ec2_vpc_id`: the ID of the VPC in which the instance is running, if available - -#### `lightsail` - -The `lightsail` role discovers targets from [AWS Lightsail](https://aws.amazon.com/lightsail/) -instances. The private IP address is used by default, but may be changed to -the public IP address with relabeling. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_lightsail_availability_zone`: the availability zone in which the instance is running -* `__meta_lightsail_blueprint_id`: the Lightsail blueprint ID -* `__meta_lightsail_bundle_id`: the Lightsail bundle ID -* `__meta_lightsail_instance_name`: the name of the Lightsail instance -* `__meta_lightsail_instance_state`: the state of the Lightsail instance -* `__meta_lightsail_instance_support_code`: the support code of the Lightsail instance -* `__meta_lightsail_ipv6_addresses`: comma separated list of IPv6 addresses assigned to the instance's network interfaces, if present -* `__meta_lightsail_private_ip`: the private IP address of the instance -* `__meta_lightsail_public_ip`: the public IP address of the instance, if available -* `__meta_lightsail_region`: the region of the instance -* `__meta_lightsail_tag_`: each tag value of the instance - -#### `ecs` - -The `ecs` role discovers targets from AWS ECS containers. - -ECS service discovery supports all ECS networking modes: -- **awsvpc mode** (Fargate and EC2 with ENI): Uses the task's private IP address from its elastic network interface -- **bridge mode** (EC2): Uses the EC2 host instance's private IP address -- **host mode** (EC2): Uses the EC2 host instance's private IP address - -The private IP address is used by default, but may be changed to the public IP address with relabeling. - -The IAM credentials used must have the following permissions to discover scrape targets: - -- `ecs:ListClusters` -- `ecs:DescribeClusters` -- `ecs:ListServices` -- `ecs:DescribeServices` -- `ecs:ListTasks` -- `ecs:DescribeTasks` -- `ecs:DescribeContainerInstances` (required for EC2 launch type tasks) -- `ec2:DescribeInstances` (required for EC2 launch type tasks) -- `ec2:DescribeNetworkInterfaces` (required to get public IP for awsvpc mode tasks) - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_ecs_cluster`: the name of the ECS cluster -* `__meta_ecs_cluster_arn`: the ARN of the ECS cluster -* `__meta_ecs_service`: the name of the ECS service -* `__meta_ecs_service_arn`: the ARN of the ECS service -* `__meta_ecs_service_status`: the status of the ECS service -* `__meta_ecs_task_group`: the ECS task group (typically service:service-name) -* `__meta_ecs_task_arn`: the ARN of the ECS task -* `__meta_ecs_task_definition`: the ARN of the ECS task definition -* `__meta_ecs_ip_address`: the private IP address of the task -* `__meta_ecs_launch_type`: the launch type of the task (EC2 or Fargate) -* `__meta_ecs_desired_status`: the desired status of the task -* `__meta_ecs_last_status`: the last known status of the task -* `__meta_ecs_health_status`: the health status of the task -* `__meta_ecs_platform_family`: the platform family (e.g., Linux, Windows) -* `__meta_ecs_platform_version`: the platform version -* `__meta_ecs_subnet_id`: the subnet ID where the task is running -* `__meta_ecs_availability_zone`: the availability zone where the task is running -* `__meta_ecs_region`: the AWS region -* `__meta_ecs_public_ip`: the public IP address (from ENI for awsvpc mode, from EC2 instance for bridge/host mode), if available -* `__meta_ecs_network_mode`: the network mode of the task (awsvpc or bridge) -* `__meta_ecs_container_instance_arn`: the ARN of the container instance (EC2 launch type only) -* `__meta_ecs_ec2_instance_id`: the EC2 instance ID (EC2 launch type only) -* `__meta_ecs_ec2_instance_type`: the EC2 instance type (EC2 launch type only) -* `__meta_ecs_ec2_instance_private_ip`: the private IP address of the EC2 instance (EC2 launch type only) -* `__meta_ecs_ec2_instance_public_ip`: the public IP address of the EC2 instance, if available (EC2 launch type only) -* `__meta_ecs_tag_cluster_`: each cluster tag value, keyed by tag name -* `__meta_ecs_tag_service_`: each service tag value, keyed by tag name -* `__meta_ecs_tag_task_`: each task tag value, keyed by tag name -* `__meta_ecs_tag_ec2_`: each EC2 instance tag value, keyed by tag name (EC2 launch type only) - -#### `msk` - -The `msk` role discovers targets from AWS MSK (Managed Streaming for Apache Kafka) provisioned clusters. - -**Important**: This service discovery only works with **provisioned clusters**. Serverless clusters are not supported as they do not expose individual broker nodes. - -Discovery includes: -- **Broker nodes**: Kafka broker instances (supports both ZooKeeper-based and KRaft-based clusters) -- **KRaft Controller nodes**: Controller instances (KRaft-based clusters only) - -Note: ZooKeeper nodes are not discoverable via the MSK API. For monitoring, MSK provides: -- **JMX Exporter**: Available on both broker and KRaft controller nodes (when enabled) -- **Node Exporter**: Available on broker nodes only (when enabled) - -The IAM credentials used must have the following permissions to discover -scrape targets: - -- `kafka:DescribeClusterV2` -- `kafka:ListClustersV2` -- `kafka:ListNodes` - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_msk_cluster_name`: the name of the MSK cluster -* `__meta_msk_cluster_arn`: the ARN of the MSK cluster -* `__meta_msk_cluster_state`: the state of the MSK cluster (e.g., ACTIVE, CREATING, DELETING) -* `__meta_msk_cluster_type`: the type of the MSK cluster (e.g., PROVISIONED, SERVERLESS) -* `__meta_msk_cluster_version`: the current version of the MSK cluster -* `__meta_msk_cluster_kafka_version`: the Kafka version running on the cluster -* `__meta_msk_cluster_jmx_exporter_enabled`: whether JMX exporter is enabled on the cluster -* `__meta_msk_cluster_configuration_arn`: the ARN of the MSK configuration -* `__meta_msk_cluster_configuration_revision`: the revision of the MSK configuration -* `__meta_msk_cluster_tag_`: each cluster tag value, keyed by tag name -* `__meta_msk_node_type`: the type of the node (BROKER or CONTROLLER) -* `__meta_msk_node_arn`: the ARN of the node -* `__meta_msk_node_added_time`: the time the node was added to the cluster -* `__meta_msk_node_instance_type`: the instance type of the node -* `__meta_msk_node_attached_eni`: the ID of the attached ENI -* `__meta_msk_broker_id`: the broker ID (broker nodes only) -* `__meta_msk_broker_endpoint_index`: the index of the broker endpoint (broker nodes only) -* `__meta_msk_broker_client_subnet`: the client subnet of the broker (broker nodes only) -* `__meta_msk_broker_client_vpc_ip`: the VPC IP address of the broker (broker nodes only) -* `__meta_msk_broker_node_exporter_enabled`: whether node exporter is enabled on brokers (broker nodes only) -* `__meta_msk_controller_endpoint_index`: the index of the controller endpoint (controller nodes only) - -#### `elasticache` - -The `elasticache` role discovers targets from AWS ElastiCache for both serverless caches and cache clusters. - -**Important**: For cache clusters, one target is created per cache node. Each target includes the cluster-level labels (ARN, status, tags, etc.) and node-specific labels (node ID, endpoint, availability zone, etc.). The `__address__` label is set to the individual node's endpoint address and port. - -For serverless caches, one target is created per serverless cache, with the `__address__` label set to the serverless cache endpoint. - -The IAM credentials used must have the following permissions to discover scrape targets: - -- `elasticache:DescribeServerlessCaches` -- `elasticache:DescribeCacheClusters` -- `elasticache:ListTagsForResource` - -The following meta labels are available on targets during [relabeling](#relabel_config): - -**Common labels (available on all targets):** - -* `__meta_elasticache_deployment_option`: the deployment option - either `serverless` for serverless caches or `node` for cache cluster nodes - -**Serverless Cache labels:** - -* `__meta_elasticache_serverless_cache_arn`: the ARN of the serverless cache -* `__meta_elasticache_serverless_cache_name`: the name of the serverless cache -* `__meta_elasticache_serverless_cache_status`: the status of the serverless cache -* `__meta_elasticache_serverless_cache_engine`: the cache engine (redis or valkey) -* `__meta_elasticache_serverless_cache_full_engine_version`: the full engine version -* `__meta_elasticache_serverless_cache_major_engine_version`: the major engine version -* `__meta_elasticache_serverless_cache_description`: the description of the serverless cache -* `__meta_elasticache_serverless_cache_create_time`: the creation time in RFC3339 format -* `__meta_elasticache_serverless_cache_snapshot_retention_limit`: the snapshot retention limit in days -* `__meta_elasticache_serverless_cache_daily_snapshot_time`: the daily snapshot time -* `__meta_elasticache_serverless_cache_user_group_id`: the user group ID -* `__meta_elasticache_serverless_cache_kms_key_id`: the KMS key ID for encryption at rest -* `__meta_elasticache_serverless_cache_endpoint_address`: the endpoint address -* `__meta_elasticache_serverless_cache_endpoint_port`: the endpoint port -* `__meta_elasticache_serverless_cache_reader_endpoint_address`: the reader endpoint address -* `__meta_elasticache_serverless_cache_reader_endpoint_port`: the reader endpoint port -* `__meta_elasticache_serverless_cache_security_group_id_`: security group IDs (indexed) -* `__meta_elasticache_serverless_cache_subnet_id_`: subnet IDs (indexed) -* `__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_maximum`: maximum data storage in the specified unit -* `__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_minimum`: minimum data storage in the specified unit -* `__meta_elasticache_serverless_cache_cache_usage_limit_data_storage_unit`: unit for data storage (e.g., GB) -* `__meta_elasticache_serverless_cache_cache_usage_limit_ecpu_per_second_maximum`: maximum ECPU per second -* `__meta_elasticache_serverless_cache_cache_usage_limit_ecpu_per_second_minimum`: minimum ECPU per second -* `__meta_elasticache_serverless_cache_tag_`: each serverless cache tag value, keyed by tag name - -**Cache Cluster labels:** - -* `__meta_elasticache_cache_cluster_arn`: the ARN of the cache cluster -* `__meta_elasticache_cache_cluster_cache_cluster_id`: the cache cluster ID -* `__meta_elasticache_cache_cluster_cache_cluster_status`: the status of the cache cluster -* `__meta_elasticache_cache_cluster_engine`: the cache engine (redis or memcached) -* `__meta_elasticache_cache_cluster_engine_version`: the engine version -* `__meta_elasticache_cache_cluster_cache_node_type`: the cache node type (e.g., cache.t3.micro) -* `__meta_elasticache_cache_cluster_num_cache_nodes`: the number of cache nodes -* `__meta_elasticache_cache_cluster_cache_cluster_create_time`: the creation time in RFC3339 format -* `__meta_elasticache_cache_cluster_at_rest_encryption_enabled`: whether encryption at rest is enabled -* `__meta_elasticache_cache_cluster_transit_encryption_enabled`: whether encryption in transit is enabled -* `__meta_elasticache_cache_cluster_transit_encryption_mode`: the transit encryption mode -* `__meta_elasticache_cache_cluster_auth_token_enabled`: whether auth token is enabled -* `__meta_elasticache_cache_cluster_auth_token_last_modified`: the last modification time of auth token -* `__meta_elasticache_cache_cluster_auto_minor_version_upgrade`: whether auto minor version upgrade is enabled -* `__meta_elasticache_cache_cluster_cache_parameter_group`: the cache parameter group name -* `__meta_elasticache_cache_cluster_cache_subnet_group_name`: the cache subnet group name -* `__meta_elasticache_cache_cluster_client_download_landing_page`: the client download landing page URL -* `__meta_elasticache_cache_cluster_ip_discovery`: the IP discovery mode (ipv4 or ipv6) -* `__meta_elasticache_cache_cluster_network_type`: the network type (ipv4, ipv6, or dual_stack) -* `__meta_elasticache_cache_cluster_preferred_availability_zone`: the preferred availability zone -* `__meta_elasticache_cache_cluster_preferred_maintenance_window`: the preferred maintenance window -* `__meta_elasticache_cache_cluster_preferred_outpost_arn`: the preferred outpost ARN -* `__meta_elasticache_cache_cluster_replication_group_id`: the replication group ID (for Redis clusters that are part of a replication group) -* `__meta_elasticache_cache_cluster_replication_group_log_delivery_enabled`: whether log delivery is enabled for the replication group -* `__meta_elasticache_cache_cluster_snapshot_retention_limit`: the snapshot retention limit in days -* `__meta_elasticache_cache_cluster_snapshot_window`: the daily snapshot window -* `__meta_elasticache_cache_cluster_configuration_endpoint_address`: the configuration endpoint address (cluster mode enabled only) -* `__meta_elasticache_cache_cluster_configuration_endpoint_port`: the configuration endpoint port (cluster mode enabled only) -* `__meta_elasticache_cache_cluster_notification_topic_arn`: the SNS topic ARN for notifications -* `__meta_elasticache_cache_cluster_notification_topic_status`: the SNS topic status -* `__meta_elasticache_cache_cluster_log_delivery_configuration_destination_type_`: log delivery destination type (cloudwatch-logs or kinesis-firehose) -* `__meta_elasticache_cache_cluster_log_delivery_configuration_log_format_`: log format (text or json) -* `__meta_elasticache_cache_cluster_log_delivery_configuration_log_type_`: log type (slow-log or engine-log) -* `__meta_elasticache_cache_cluster_log_delivery_configuration_status_`: log delivery status -* `__meta_elasticache_cache_cluster_log_delivery_configuration_message_`: log delivery message -* `__meta_elasticache_cache_cluster_log_delivery_configuration_log_group_`: CloudWatch log group name (cloudwatch-logs destination only) -* `__meta_elasticache_cache_cluster_log_delivery_configuration_delivery_stream_`: Kinesis Firehose delivery stream name (kinesis-firehose destination only) -* `__meta_elasticache_cache_cluster_pending_modified_values_auth_token_status`: pending auth token status -* `__meta_elasticache_cache_cluster_pending_modified_values_cache_node_type`: pending cache node type change -* `__meta_elasticache_cache_cluster_pending_modified_values_engine_version`: pending engine version upgrade -* `__meta_elasticache_cache_cluster_pending_modified_values_num_cache_nodes`: pending number of cache nodes -* `__meta_elasticache_cache_cluster_pending_modified_values_transit_encryption_enabled`: pending transit encryption status -* `__meta_elasticache_cache_cluster_pending_modified_values_transit_encryption_mode`: pending transit encryption mode -* `__meta_elasticache_cache_cluster_pending_modified_values_cache_node_ids_to_remove`: comma-separated list of cache node IDs to be removed -* `__meta_elasticache_cache_cluster_security_group_membership_id_`: security group ID (indexed) -* `__meta_elasticache_cache_cluster_security_group_membership_status_`: security group status (indexed) -* `__meta_elasticache_cache_cluster_node_id`: cache node ID -* `__meta_elasticache_cache_cluster_node_status`: cache node status -* `__meta_elasticache_cache_cluster_node_create_time`: cache node creation time in RFC3339 format -* `__meta_elasticache_cache_cluster_node_availability_zone`: cache node availability zone -* `__meta_elasticache_cache_cluster_node_customer_outpost_arn`: cache node outpost ARN -* `__meta_elasticache_cache_cluster_node_source_cache_node_id`: source cache node ID for replication -* `__meta_elasticache_cache_cluster_node_parameter_group_status`: parameter group status -* `__meta_elasticache_cache_cluster_node_endpoint_address`: cache node endpoint address -* `__meta_elasticache_cache_cluster_node_endpoint_port`: cache node endpoint port -* `__meta_elasticache_cache_cluster_tag_`: each cache cluster tag value, keyed by tag name - -#### `rds` - -The `rds` role discovers targets from [AWS RDS](https://aws.amazon.com/rds/) -database instances within clusters. One target is created for each DB instance -within the specified clusters. The endpoint address and port of each instance is used by default. - -The IAM credentials used must have the `rds:DescribeDBClusters` and `rds:DescribeDBInstances` -permissions to discover scrape targets. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -**Cluster labels:** - -* `__meta_rds_cluster_activity_stream_kinesis_stream_name`: the name of the Amazon Kinesis data stream used for database activity stream -* `__meta_rds_cluster_activity_stream_kms_key_id`: the AWS KMS key identifier used for encrypting the database activity stream -* `__meta_rds_cluster_activity_stream_mode`: the mode of the database activity stream (sync or async) -* `__meta_rds_cluster_activity_stream_status`: the status of the database activity stream -* `__meta_rds_cluster_allocated_storage`: the allocated storage size in gibibytes (GiB) -* `__meta_rds_cluster_arn`: the Amazon Resource Name (ARN) of the DB cluster -* `__meta_rds_cluster_auto_minor_version_upgrade`: whether automatic minor version upgrades are enabled -* `__meta_rds_cluster_automatic_restart_time`: the time when a stopped cluster will be automatically restarted -* `__meta_rds_cluster_aws_backup_recovery_point_arn`: the ARN of the recovery point in AWS Backup -* `__meta_rds_cluster_backtrack_consumed_change_records`: the number of change records stored for backtrack -* `__meta_rds_cluster_backtrack_window`: the target backtrack window in hours -* `__meta_rds_cluster_backup_retention_period`: the number of days for which automated backups are retained -* `__meta_rds_cluster_capacity`: the current capacity of an Aurora Serverless DB cluster -* `__meta_rds_cluster_character_set_name`: the name of the character set -* `__meta_rds_cluster_clone_group_id`: the ID of the clone group -* `__meta_rds_cluster_cluster_create_time`: the time when the DB cluster was created -* `__meta_rds_cluster_cluster_scalability_type`: the scalability type of the cluster -* `__meta_rds_cluster_copy_tags_to_snapshot`: whether tags are copied from the cluster to snapshots -* `__meta_rds_cluster_cross_account_clone`: whether the DB cluster is a cross-account clone -* `__meta_rds_cluster_database_insights_mode`: the mode of Database Insights -* `__meta_rds_cluster_database_name`: the database name -* `__meta_rds_cluster_db_system_id`: the Oracle system ID (Oracle SID) -* `__meta_rds_cluster_deletion_protection`: whether deletion protection is enabled -* `__meta_rds_cluster_earliest_backtrack_time`: the earliest time to which a database can be restored with backtrack -* `__meta_rds_cluster_earliest_restorable_time`: the earliest time to which a database can be restored -* `__meta_rds_cluster_endpoint`: the endpoint of the DB cluster -* `__meta_rds_cluster_engine_lifecycle_support`: the engine lifecycle support value -* `__meta_rds_cluster_engine_mode`: the engine mode of the cluster (provisioned, serverless, etc.) -* `__meta_rds_cluster_engine_version`: the version of the database engine -* `__meta_rds_cluster_engine`: the database engine of the DB cluster -* `__meta_rds_cluster_global_cluster_identifier`: the identifier of the global cluster -* `__meta_rds_cluster_global_write_forwarding_requested`: whether global write forwarding is requested -* `__meta_rds_cluster_global_write_forwarding_status`: the status of global write forwarding -* `__meta_rds_cluster_hosted_zone_id`: the Route 53 hosted zone ID -* `__meta_rds_cluster_http_endpoint_enabled`: whether the HTTP endpoint is enabled -* `__meta_rds_cluster_iam_database_authentication_enabled`: whether the DB cluster has IAM database authentication enabled -* `__meta_rds_cluster_identifier`: the identifier of the DB cluster -* `__meta_rds_cluster_instance_class`: the compute and memory capacity class of the DB cluster -* `__meta_rds_cluster_io_optimized_next_allowed_modification_time`: the time when the next IO optimization configuration change is allowed -* `__meta_rds_cluster_iops`: the provisioned IOPS (I/O operations per second) value -* `__meta_rds_cluster_kms_key_id`: the AWS KMS key identifier for the encrypted cluster -* `__meta_rds_cluster_latest_restorable_time`: the latest time to which a database can be restored -* `__meta_rds_cluster_local_write_forwarding_status`: the status of local write forwarding -* `__meta_rds_cluster_master_username`: the master username -* `__meta_rds_cluster_monitoring_interval`: the interval in seconds between enhanced monitoring metrics collection -* `__meta_rds_cluster_monitoring_role_arn`: the ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch -* `__meta_rds_cluster_multi_az`: whether the DB cluster is multi-AZ -* `__meta_rds_cluster_network_type`: the network type (IPV4 or DUAL) -* `__meta_rds_cluster_parameter_group`: the name of the DB cluster parameter group -* `__meta_rds_cluster_percent_progress`: the progress percentage of the DB cluster operation -* `__meta_rds_cluster_performance_insights_enabled`: whether Performance Insights is enabled -* `__meta_rds_cluster_performance_insights_kms_key_id`: the AWS KMS key identifier for encrypting Performance Insights data -* `__meta_rds_cluster_performance_insights_retention_period`: the retention period for Performance Insights data -* `__meta_rds_cluster_port`: the port the DB cluster is listening on -* `__meta_rds_cluster_preferred_backup_window`: the daily time range during which automated backups are created -* `__meta_rds_cluster_preferred_maintenance_window`: the weekly time range during which system maintenance can occur -* `__meta_rds_cluster_publicly_accessible`: whether the DB cluster is publicly accessible -* `__meta_rds_cluster_reader_endpoint`: the reader endpoint of the DB cluster -* `__meta_rds_cluster_replication_source_identifier`: the identifier of the source DB cluster if this is a read replica -* `__meta_rds_cluster_resource_id`: the AWS Region-unique immutable identifier for the DB cluster -* `__meta_rds_cluster_serverless_v2_platform_version`: the platform version of the Aurora Serverless v2 DB cluster -* `__meta_rds_cluster_status`: the status of the DB cluster -* `__meta_rds_cluster_storage_encrypted`: whether the DB cluster is storage encrypted -* `__meta_rds_cluster_storage_encryption_type`: the storage encryption type -* `__meta_rds_cluster_storage_throughput`: the storage throughput in MiBps -* `__meta_rds_cluster_storage_type`: the storage type -* `__meta_rds_cluster_subnet_group`: the name of the subnet group associated with the DB cluster -* `__meta_rds_cluster_tag_`: each tag value of the DB cluster -* `__meta_rds_cluster_upgrade_rollout_order`: the upgrade rollout order - -**Instance labels:** - -* `__meta_rds_instance_activity_stream_engine_native_audit_fields_included`: whether engine-native audit fields are included in the database activity stream -* `__meta_rds_instance_activity_stream_kinesis_stream_name`: the name of the Amazon Kinesis data stream used for the database activity stream -* `__meta_rds_instance_activity_stream_kms_key_id`: the AWS KMS key identifier used for encrypting the database activity stream -* `__meta_rds_instance_activity_stream_mode`: the mode of the database activity stream (sync or async) -* `__meta_rds_instance_activity_stream_policy_status`: the policy status of the database activity stream -* `__meta_rds_instance_activity_stream_status`: the status of the database activity stream -* `__meta_rds_instance_allocated_storage`: the allocated storage size in gibibytes (GiB) -* `__meta_rds_instance_arn`: the Amazon Resource Name (ARN) of the DB instance -* `__meta_rds_instance_auto_minor_version_upgrade`: whether automatic minor version upgrades are enabled -* `__meta_rds_instance_automatic_restart_time`: the time when a stopped instance will be automatically restarted -* `__meta_rds_instance_automation_mode`: the automation mode of the instance -* `__meta_rds_instance_availability_zone`: the availability zone of the DB instance -* `__meta_rds_instance_aws_backup_recovery_point_arn`: the ARN of the recovery point in AWS Backup -* `__meta_rds_instance_backup_retention_period`: the number of days for which automated backups are retained -* `__meta_rds_instance_backup_target`: the backup target (region or outposts) -* `__meta_rds_instance_ca_certificate_identifier`: the identifier of the CA certificate for the DB instance -* `__meta_rds_instance_character_set_name`: the name of the character set -* `__meta_rds_instance_class`: the compute and memory capacity class of the DB instance -* `__meta_rds_instance_copy_tags_to_snapshot`: whether tags are copied from the instance to snapshots -* `__meta_rds_instance_custom_iam_instance_profile`: the instance profile associated with the underlying Amazon EC2 instance -* `__meta_rds_instance_customer_owned_ip_enabled`: whether a customer-owned IP address (CoIP) is enabled -* `__meta_rds_instance_database_insights_mode`: the mode of Database Insights -* `__meta_rds_instance_db_cluster_identifier`: the identifier of the DB cluster this instance is a member of -* `__meta_rds_instance_db_name`: the database name -* `__meta_rds_instance_db_system_id`: the Oracle system ID (Oracle SID) -* `__meta_rds_instance_dedicated_log_volume`: whether the DB instance has a dedicated log volume -* `__meta_rds_instance_deletion_protection`: whether deletion protection is enabled -* `__meta_rds_instance_endpoint_address`: the DNS address of the DB instance -* `__meta_rds_instance_endpoint_hosted_zone_id`: the Route 53 hosted zone ID of the endpoint -* `__meta_rds_instance_endpoint_port`: the port that the DB instance listens on -* `__meta_rds_instance_engine_lifecycle_support`: the engine lifecycle support value -* `__meta_rds_instance_engine_version`: the version of the database engine -* `__meta_rds_instance_engine`: the database engine that the DB instance uses -* `__meta_rds_instance_enhanced_monitoring_resource_arn`: the ARN of the Amazon CloudWatch Logs log stream for enhanced monitoring -* `__meta_rds_instance_iam_database_authentication_enabled`: whether IAM database authentication is enabled -* `__meta_rds_instance_identifier`: the identifier of the DB instance -* `__meta_rds_instance_instance_create_time`: the time when the DB instance was created -* `__meta_rds_instance_iops`: the provisioned IOPS (I/O operations per second) value -* `__meta_rds_instance_is_cluster_writer`: whether the instance is the cluster writer (true/false) -* `__meta_rds_instance_is_storage_config_upgrade_available`: whether a storage configuration upgrade is available -* `__meta_rds_instance_kms_key_id`: the AWS KMS key identifier for the encrypted instance -* `__meta_rds_instance_latest_restorable_time`: the latest time to which a database can be restored -* `__meta_rds_instance_license_model`: the license model information -* `__meta_rds_instance_listener_endpoint_address`: the DNS address of the listener endpoint -* `__meta_rds_instance_listener_endpoint_hosted_zone_id`: the Route 53 hosted zone ID of the listener endpoint -* `__meta_rds_instance_listener_endpoint_port`: the port that the listener endpoint listens on -* `__meta_rds_instance_master_username`: the master username -* `__meta_rds_instance_max_allocated_storage`: the upper limit in gibibytes to which storage can be scaled automatically -* `__meta_rds_instance_monitoring_interval`: the interval in seconds between enhanced monitoring metrics collection -* `__meta_rds_instance_monitoring_role_arn`: the ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch -* `__meta_rds_instance_multi_az`: whether the DB instance is a Multi-AZ deployment -* `__meta_rds_instance_multi_tenant`: whether the instance is in a multi-tenant configuration -* `__meta_rds_instance_nchar_character_set_name`: the national character set name -* `__meta_rds_instance_network_type`: the network type (IPV4 or DUAL) -* `__meta_rds_instance_percent_progress`: the progress percentage of the DB instance operation -* `__meta_rds_instance_performance_insights_enabled`: whether Performance Insights is enabled -* `__meta_rds_instance_performance_insights_kms_key_id`: the AWS KMS key identifier for encrypting Performance Insights data -* `__meta_rds_instance_performance_insights_retention_period`: the retention period for Performance Insights data -* `__meta_rds_instance_port`: the port that the DB instance listens on -* `__meta_rds_instance_preferred_backup_window`: the daily time range during which automated backups are created -* `__meta_rds_instance_preferred_maintenance_window`: the weekly time range during which system maintenance can occur -* `__meta_rds_instance_promotion_tier`: the order in which an Aurora replica is promoted to primary instance after a failure -* `__meta_rds_instance_publicly_accessible`: whether the DB instance is publicly accessible -* `__meta_rds_instance_read_replica_source_db_cluster_identifier`: the identifier of the source DB cluster if this instance is a read replica -* `__meta_rds_instance_read_replica_source_db_instance_identifier`: the identifier of the source DB instance if this instance is a read replica -* `__meta_rds_instance_replica_mode`: the replica mode (open-read-only or mounted) -* `__meta_rds_instance_resource_id`: the AWS Region-unique immutable identifier for the DB instance -* `__meta_rds_instance_resume_full_automation_mode_time`: the time when the DB instance will resume full automation -* `__meta_rds_instance_secondary_availability_zone`: the secondary availability zone for Multi-AZ instances -* `__meta_rds_instance_status`: the status of the DB instance -* `__meta_rds_instance_storage_encrypted`: whether the DB instance is storage encrypted -* `__meta_rds_instance_storage_encryption_type`: the storage encryption type -* `__meta_rds_instance_storage_throughput`: the storage throughput in MiBps -* `__meta_rds_instance_storage_type`: the storage type -* `__meta_rds_instance_storage_volume_status`: the status of the storage volume -* `__meta_rds_instance_subnet_group`: the name of the subnet group associated with the DB instance -* `__meta_rds_instance_tag_`: each tag value of the DB instance -* `__meta_rds_instance_tde_credential_arn`: the ARN for the TDE encryption key -* `__meta_rds_instance_timezone`: the time zone of the DB instance -* `__meta_rds_instance_upgrade_rollout_order`: the upgrade rollout order - -See below for the configuration options for AWS discovery: - -```yaml -# The AWS role to use for service discovery. -# Must be one of: ec2, lightsail, ecs, msk, elasticache, or rds. -role: - -# The AWS region. If blank, the region from the instance metadata is used. -[ region: ] - -# Custom endpoint to be used. -[ endpoint: ] - -# AWS access key ID. If blank, the environment variable AWS_ACCESS_KEY_ID is used. -[ access_key: ] - -# AWS secret access key. If blank, the environment variable AWS_SECRET_ACCESS_KEY is used. -[ secret_key: ] - -# Named AWS profile used to authenticate. -[ profile: ] - -# AWS Role ARN, an alternative to using AWS API keys. -[ role_arn: ] - -# Optional External ID that can go along with role_arn. -[ external_id: ] - -# Refresh interval to re-read the targets list. -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# Filters can be used optionally to filter the instance list by other criteria (ec2 & rds role only). -# Available filter criteria can be found here: -# EC2: -# - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html -# - Filter API documentation: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Filter.html -# RDS: -# - https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html -# - Filter API documentation: https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_Filter.html -filters: - [ - name: - values: , [...] ] - -# List of ECS, ElastiCache, MSK, or RDS cluster identifiers (ecs, elasticache, msk, and rds roles only) to discover. -# A List of ARNs of clusters to discover. If empty, all clusters in the region are discovered. -# This can significantly improve performance when you only need to monitor specific clusters/caches. -[ clusters: [, ...] ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Azure SD configurations allow retrieving scrape targets from Azure VMs. - -The discovery requires at least the following permissions: - -* `Microsoft.Compute/virtualMachines/read`: Required for VM discovery -* `Microsoft.Network/networkInterfaces/read`: Required for VM discovery -* `Microsoft.Compute/virtualMachineScaleSets/virtualMachines/read`: Required for scale set (VMSS) discovery -* `Microsoft.Compute/virtualMachineScaleSets/virtualMachines/networkInterfaces/read`: Required for scale set (VMSS) discovery - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_azure_machine_id`: the machine ID -* `__meta_azure_machine_location`: the location the machine runs in -* `__meta_azure_machine_name`: the machine name -* `__meta_azure_machine_computer_name`: the machine computer name -* `__meta_azure_machine_os_type`: the machine operating system -* `__meta_azure_machine_private_ip`: the machine's private IP -* `__meta_azure_machine_public_ip`: the machine's public IP if it exists -* `__meta_azure_machine_resource_group`: the machine's resource group -* `__meta_azure_machine_tag_`: each tag value of the machine -* `__meta_azure_machine_scale_set`: the name of the scale set which the vm is part of (this value is only set if you are using a [scale set](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/)) -* `__meta_azure_machine_size`: the machine size -* `__meta_azure_subscription_id`: the subscription ID -* `__meta_azure_tenant_id`: the tenant ID - -See below for the configuration options for Azure discovery: - -```yaml -# The information to access the Azure API. -# The Azure environment. -[ environment: | default = AzurePublicCloud ] - -# The authentication method, either OAuth, ManagedIdentity or SDK. -# See https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview -# SDK authentication method uses environment variables by default. -# See https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication -[ authentication_method: | default = OAuth] -# The subscription ID. Always required. -subscription_id: -# Optional tenant ID. Only required with authentication_method OAuth. -[ tenant_id: ] -# Optional client ID. Only required with authentication_method OAuth. -[ client_id: ] -# Optional client secret. Only required with authentication_method OAuth. -[ client_secret: ] - -# Optional resource group name. Limits discovery to this resource group. -[ resource_group: ] - -# Refresh interval to re-read the instance list. -[ refresh_interval: | default = 300s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Consul SD configurations allow retrieving scrape targets from [Consul's](https://www.consul.io) -service catalog. Discovery uses two Consul API endpoints: - -1. The [Catalog API](https://developer.hashicorp.com/consul/api-docs/catalog) to list services - (used when `services` is empty, or when `tags` or `filter` are set). -2. The [Health API](https://developer.hashicorp.com/consul/api-docs/health) to retrieve service - instances and their health status. - -Because these two APIs have different filtering field schemas, Prometheus exposes separate filter -options for each: `filter` applies to the Catalog API and `health_filter` applies to the Health API. -For example, tags are exposed as `ServiceTags` in the Catalog API but as `Service.Tags` in the -Health API. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_consul_address`: the address of the target -* `__meta_consul_dc`: the datacenter name for the target -* `__meta_consul_health`: the health status of the service -* `__meta_consul_partition`: the admin partition name where the service is registered -* `__meta_consul_metadata_`: each node metadata key value of the target -* `__meta_consul_node`: the node name defined for the target -* `__meta_consul_service_address`: the service address of the target -* `__meta_consul_service_id`: the service ID of the target -* `__meta_consul_service_metadata_`: each service metadata key value of the target -* `__meta_consul_service_port`: the service port of the target -* `__meta_consul_service`: the name of the service the target belongs to -* `__meta_consul_tagged_address_`: each node tagged address key value of the target -* `__meta_consul_tags`: the list of tags of the target joined by the tag separator - -```yaml -# The information to access the Consul API. It is to be defined -# as the Consul documentation requires. -[ server: | default = "localhost:8500" ] -# Prefix for URIs for when consul is behind an API gateway (reverse proxy). -[ path_prefix: ] -[ token: ] -[ datacenter: ] -# Namespaces are only supported in Consul Enterprise. -[ namespace: ] -# Admin Partitions are only supported in Consul Enterprise. -[ partition: ] -[ scheme: | default = "http" ] -# The username and password fields are deprecated in favor of the basic_auth configuration. -[ username: ] -[ password: ] - -# A list of services for which targets are retrieved. If omitted, all services -# are scraped. -services: - [ - ] - -# Filter expression for the Catalog API. See https://developer.hashicorp.com/consul/api-docs/catalog#filtering for syntax. -[ filter: ] - -# Filter expression for the Health API. See https://developer.hashicorp.com/consul/api-docs/health#filtering for syntax. -[ health_filter: ] - -# The `tags` and `node_meta` fields are deprecated in favor of `filter` and `health_filter`. -# An optional list of tags used to filter nodes for a given service. Services must contain all tags in the list. -tags: - [ - ] - -# Node metadata key/value pairs to filter nodes for a given service. As of Consul 1.14, consider `filter` or `health_filter` instead. -[ node_meta: - [ : ... ] ] - -# The string by which Consul tags are joined into the tag label. -[ tag_separator: | default = , ] - -# Allow stale Consul results (see https://www.consul.io/api/features/consistency.html). Will reduce load on Consul. -[ allow_stale: | default = true ] - -# The time after which the provided names are refreshed. -# On large setup it might be a good idea to increase this value because the catalog will change all the time. -[ refresh_interval: | default = 30s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -Note that the IP number and port used to scrape the targets is assembled as -`<__meta_consul_address>:<__meta_consul_service_port>`. However, in some -Consul setups, the relevant address is in `__meta_consul_service_address`. -In those cases, you can use the [relabel](#relabel_config) -feature to replace the special `__address__` label. - -The [relabeling phase](#relabel_config) is the preferred and more powerful -way to filter services or nodes for a service based on arbitrary labels. For -users with thousands of services it can be more efficient to use the Consul API -directly which has basic support for filtering nodes (currently by node -metadata and a single tag). - -### `` - -DigitalOcean SD configurations allow retrieving scrape targets from [DigitalOcean's](https://www.digitalocean.com/) -API. -This service discovery supports multiple roles through the `role` parameter. - -One of the following `role` types can be configured to discover targets: - -#### `droplets` - -The `droplets` role discovers targets from DigitalOcean Droplets. The public IPv4 address is used by default, -but may be changed with relabeling. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_digitalocean_droplet_id`: the id of the droplet -* `__meta_digitalocean_droplet_name`: the name of the droplet -* `__meta_digitalocean_image`: the slug of the droplet's image -* `__meta_digitalocean_image_name`: the display name of the droplet's image -* `__meta_digitalocean_private_ipv4`: the private IPv4 of the droplet -* `__meta_digitalocean_public_ipv4`: the public IPv4 of the droplet -* `__meta_digitalocean_public_ipv6`: the public IPv6 of the droplet -* `__meta_digitalocean_region`: the region of the droplet -* `__meta_digitalocean_size`: the size of the droplet -* `__meta_digitalocean_status`: the status of the droplet -* `__meta_digitalocean_features`: the comma-separated list of features of the droplet -* `__meta_digitalocean_tags`: the comma-separated list of tags of the droplet -* `__meta_digitalocean_vpc`: the id of the droplet's VPC - -#### `databases` - -The `databases` role discovers targets from DigitalOcean Managed Databases. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_digitalocean_db_id`: the id of the database cluster -* `__meta_digitalocean_db_name`: the name of the database cluster -* `__meta_digitalocean_db_engine`: the engine of the database cluster (e.g., `pg`, `mysql`, `redis`, `mongodb`) -* `__meta_digitalocean_db_version`: the version of the engine -* `__meta_digitalocean_db_status`: the status of the database cluster -* `__meta_digitalocean_db_region`: the region of the database cluster -* `__meta_digitalocean_db_size`: the size of the database cluster -* `__meta_digitalocean_db_num_nodes`: the number of nodes in the database cluster -* `__meta_digitalocean_db_host`: the public host of the database cluster -* `__meta_digitalocean_db_private_host`: the private host of the database cluster -* `__meta_digitalocean_db_tag_`: each tag of the database cluster, with its value set to `true` - -```yaml -# The DigitalOcean role to use for service discovery. -# Must be one of: droplets or databases. -[ role: | default = droplets ] - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# The time after which the targets are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Docker SD configurations allow retrieving scrape targets from [Docker Engine](https://docs.docker.com/engine/) hosts. - -This SD discovers "containers" and will create a target for each network IP and port the container is configured to expose. - -Available meta labels: - -* `__meta_docker_container_id`: the id of the container -* `__meta_docker_container_name`: the name of the container -* `__meta_docker_container_network_mode`: the network mode of the container -* `__meta_docker_container_label_`: each label of the container, with any unsupported characters converted to an underscore -* `__meta_docker_network_id`: the ID of the network -* `__meta_docker_network_name`: the name of the network -* `__meta_docker_network_ingress`: whether the network is ingress -* `__meta_docker_network_internal`: whether the network is internal -* `__meta_docker_network_label_`: each label of the network, with any unsupported characters converted to an underscore -* `__meta_docker_network_scope`: the scope of the network -* `__meta_docker_network_ip`: the IP of the container in this network -* `__meta_docker_port_private`: the port on the container -* `__meta_docker_port_public`: the external port if a port-mapping exists -* `__meta_docker_port_public_ip`: the public IP if a port-mapping exists - -See below for the configuration options for Docker discovery: - -```yaml -# Address of the Docker daemon. -host: - -# The port to scrape metrics from, when `role` is nodes, and for discovered -# tasks and services that don't have published ports. -[ port: | default = 80 ] - -# The host to use if the container is in host networking mode. -[ host_networking_host: | default = "localhost" ] - -# Sort all non-nil networks in ascending order based on network name and -# get the first network if the container has multiple networks defined, -# thus avoiding collecting duplicate targets. -[ match_first_network: | default = true ] - -# Optional filters to limit the discovery process to a subset of available -# resources. -# The available filters are listed in the upstream documentation: -# https://docs.docker.com/engine/api/v1.40/#operation/ContainerList -[ filters: - [ - name: - values: , [...] ] - -# The time after which the containers are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -The [relabeling phase](#relabel_config) is the preferred and more powerful -way to filter containers. For users with thousands of containers it -can be more efficient to use the Docker API directly which has basic support for -filtering containers (using `filters`). - -See [this example Prometheus configuration file](/documentation/examples/prometheus-docker.yml) -for a detailed example of configuring Prometheus for Docker Engine. - -### `` - -Docker Swarm SD configurations allow retrieving scrape targets from [Docker Swarm](https://docs.docker.com/engine/swarm/) -engine. - -One of the following roles can be configured to discover targets: - -#### `services` - -The `services` role discovers all [Swarm services](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks) -and exposes their ports as targets. For each published port of a service, a -single target is generated. If a service has no published ports, a target per -service is created using the `port` parameter defined in the SD configuration. - -Available meta labels: - -* `__meta_dockerswarm_service_id`: the id of the service -* `__meta_dockerswarm_service_name`: the name of the service -* `__meta_dockerswarm_service_mode`: the mode of the service -* `__meta_dockerswarm_service_endpoint_port_name`: the name of the endpoint port, if available -* `__meta_dockerswarm_service_endpoint_port_publish_mode`: the publish mode of the endpoint port -* `__meta_dockerswarm_service_label_`: each label of the service, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_service_task_container_hostname`: the container hostname of the target, if available -* `__meta_dockerswarm_service_task_container_image`: the container image of the target -* `__meta_dockerswarm_service_updating_status`: the status of the service, if available -* `__meta_dockerswarm_network_id`: the ID of the network -* `__meta_dockerswarm_network_name`: the name of the network -* `__meta_dockerswarm_network_ingress`: whether the network is ingress -* `__meta_dockerswarm_network_internal`: whether the network is internal -* `__meta_dockerswarm_network_label_`: each label of the network, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_network_scope`: the scope of the network - -#### `tasks` - -The `tasks` role discovers all [Swarm tasks](https://docs.docker.com/engine/swarm/key-concepts/#services-and-tasks) -and exposes their ports as targets. For each published port of a task, a single -target is generated. If a task has no published ports, a target per task is -created using the `port` parameter defined in the SD configuration. - -Available meta labels: - -* `__meta_dockerswarm_container_label_`: each label of the container, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_task_id`: the id of the task -* `__meta_dockerswarm_task_container_id`: the container id of the task -* `__meta_dockerswarm_task_desired_state`: the desired state of the task -* `__meta_dockerswarm_task_slot`: the slot of the task -* `__meta_dockerswarm_task_state`: the state of the task -* `__meta_dockerswarm_task_port_publish_mode`: the publish mode of the task port -* `__meta_dockerswarm_service_id`: the id of the service -* `__meta_dockerswarm_service_name`: the name of the service -* `__meta_dockerswarm_service_mode`: the mode of the service -* `__meta_dockerswarm_service_label_`: each label of the service, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_network_id`: the ID of the network -* `__meta_dockerswarm_network_name`: the name of the network -* `__meta_dockerswarm_network_ingress`: whether the network is ingress -* `__meta_dockerswarm_network_internal`: whether the network is internal -* `__meta_dockerswarm_network_label_`: each label of the network, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_network_label`: each label of the network, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_network_scope`: the scope of the network -* `__meta_dockerswarm_node_id`: the ID of the node -* `__meta_dockerswarm_node_hostname`: the hostname of the node -* `__meta_dockerswarm_node_address`: the address of the node -* `__meta_dockerswarm_node_availability`: the availability of the node -* `__meta_dockerswarm_node_label_`: each label of the node, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_node_platform_architecture`: the architecture of the node -* `__meta_dockerswarm_node_platform_os`: the operating system of the node -* `__meta_dockerswarm_node_role`: the role of the node -* `__meta_dockerswarm_node_status`: the status of the node - -The `__meta_dockerswarm_network_*` meta labels are not populated for ports which -are published with `mode=host`. - -#### `nodes` - -The `nodes` role is used to discover [Swarm nodes](https://docs.docker.com/engine/swarm/key-concepts/#nodes). - -Available meta labels: - -* `__meta_dockerswarm_node_address`: the address of the node -* `__meta_dockerswarm_node_availability`: the availability of the node -* `__meta_dockerswarm_node_engine_version`: the version of the node engine -* `__meta_dockerswarm_node_hostname`: the hostname of the node -* `__meta_dockerswarm_node_id`: the ID of the node -* `__meta_dockerswarm_node_label_`: each label of the node, with any unsupported characters converted to an underscore -* `__meta_dockerswarm_node_manager_address`: the address of the manager component of the node -* `__meta_dockerswarm_node_manager_leader`: the leadership status of the manager component of the node (true or false) -* `__meta_dockerswarm_node_manager_reachability`: the reachability of the manager component of the node -* `__meta_dockerswarm_node_platform_architecture`: the architecture of the node -* `__meta_dockerswarm_node_platform_os`: the operating system of the node -* `__meta_dockerswarm_node_role`: the role of the node -* `__meta_dockerswarm_node_status`: the status of the node - -See below for the configuration options for Docker Swarm discovery: - -```yaml -# Address of the Docker daemon. -host: - -# Role of the targets to retrieve. Must be `services`, `tasks`, or `nodes`. -role: - -# The port to scrape metrics from, when `role` is nodes, and for discovered -# tasks and services that don't have published ports. -[ port: | default = 80 ] - -# Optional filters to limit the discovery process to a subset of available -# resources. -# The available filters are listed in the upstream documentation: -# Services: https://docs.docker.com/engine/api/v1.40/#operation/ServiceList -# Tasks: https://docs.docker.com/engine/api/v1.40/#operation/TaskList -# Nodes: https://docs.docker.com/engine/api/v1.40/#operation/NodeList -[ filters: - [ - name: - values: , [...] ] - -# The time after which the service discovery data is refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -The [relabeling phase](#relabel_config) is the preferred and more powerful -way to filter tasks, services or nodes. For users with thousands of tasks it -can be more efficient to use the Swarm API directly which has basic support for -filtering nodes (using `filters`). - -See [this example Prometheus configuration file](/documentation/examples/prometheus-dockerswarm.yml) -for a detailed example of configuring Prometheus for Docker Swarm. - -### `` - -A DNS-based service discovery configuration allows specifying a set of DNS -domain names which are periodically queried to discover a list of targets. The -DNS servers to be contacted are read from `/etc/resolv.conf`. - -This service discovery method only supports basic DNS A, AAAA, MX, NS and SRV -record queries, but not the advanced DNS-SD approach specified in -[RFC6763](https://tools.ietf.org/html/rfc6763). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_dns_name`: the record name that produced the discovered target. -* `__meta_dns_srv_record_target`: the target field of the SRV record -* `__meta_dns_srv_record_port`: the port field of the SRV record -* `__meta_dns_mx_record_target`: the target field of the MX record -* `__meta_dns_ns_record_target`: the target field of the NS record - -```yaml -# A list of DNS domain names to be queried. -names: - [ - ] - -# The type of DNS query to perform. One of SRV, A, AAAA, MX or NS. -[ type: | default = 'SRV' ] - -# The port number used if the query type is not SRV. -[ port: ] - -# The time after which the provided names are refreshed. -[ refresh_interval: | default = 30s ] -``` - -### `` - -EC2 SD configurations allow retrieving scrape targets from AWS EC2 -instances. The private IP address is used by default, but may be changed to -the public IP address with relabeling. - -The IAM credentials used must have the `ec2:DescribeInstances` permission to -discover scrape targets, and may optionally have the -`ec2:DescribeAvailabilityZones` permission if you want the availability zone ID -available as a label (see below). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_ec2_ami`: the EC2 Amazon Machine Image -* `__meta_ec2_architecture`: the architecture of the instance -* `__meta_ec2_availability_zone`: the availability zone in which the instance is running -* `__meta_ec2_availability_zone_id`: the [availability zone ID](https://docs.aws.amazon.com/ram/latest/userguide/working-with-az-ids.html) in which the instance is running (requires `ec2:DescribeAvailabilityZones`) -* `__meta_ec2_instance_id`: the EC2 instance ID -* `__meta_ec2_instance_lifecycle`: the lifecycle of the EC2 instance, set only for 'spot' or 'scheduled' instances, absent otherwise -* `__meta_ec2_instance_state`: the state of the EC2 instance -* `__meta_ec2_instance_type`: the type of the EC2 instance -* `__meta_ec2_ipv6_addresses`: comma separated list of IPv6 addresses assigned to the instance's network interfaces, if present -* `__meta_ec2_owner_id`: the ID of the AWS account that owns the EC2 instance -* `__meta_ec2_platform`: the Operating System platform, set to 'windows' on Windows servers, absent otherwise -* `__meta_ec2_default_ipv6_address`: the first primary IPv6 address found if present, otherwise first non-primary IPv6 address, if present -* `__meta_ec2_primary_ipv6_addresses`: comma separated list of the Primary IPv6 addresses of the instance, if present. The list is ordered based on the position of each corresponding network interface in the attachment order. -* `__meta_ec2_primary_subnet_id`: the subnet ID of the primary network interface, if available -* `__meta_ec2_private_dns_name`: the private DNS name of the instance, if available -* `__meta_ec2_private_ip`: the private IP address of the instance, if present -* `__meta_ec2_public_dns_name`: the public DNS name of the instance, if available -* `__meta_ec2_public_ip`: the public IP address of the instance, if available -* `__meta_ec2_region`: the region of the instance -* `__meta_ec2_subnet_id`: comma separated list of subnets IDs in which the instance is running, if available -* `__meta_ec2_tag_`: each tag value of the instance -* `__meta_ec2_vpc_id`: the ID of the VPC in which the instance is running, if available - -See below for the configuration options for EC2 discovery: - -```yaml -# The information to access the EC2 API. - -# The AWS region. If blank, the region from the instance metadata is used. -[ region: ] - -# Custom endpoint to be used. -[ endpoint: ] - -# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID` -# and `AWS_SECRET_ACCESS_KEY` are used. -[ access_key: ] -[ secret_key: ] -# Named AWS profile used to connect to the API. -[ profile: ] - -# AWS Role ARN, an alternative to using AWS API keys. -[ role_arn: ] - -# Optional External ID that can go along with role_arn. -[ external_id: ] - -# Refresh interval to re-read the instance list. -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# Filters can be used optionally to filter the instance list by other criteria. -# Available filter criteria can be found here: -# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html -# Filter API documentation: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Filter.html -filters: - [ - name: - values: , [...] ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -The [relabeling phase](#relabel_config) is the preferred and more powerful -way to filter targets based on arbitrary labels. For users with thousands of -instances it can be more efficient to use the EC2 API directly which has -support for filtering instances. - -### `` - -OpenStack SD configurations allow retrieving scrape targets from OpenStack Nova -instances. - -One of the following `` types can be configured to discover targets: - -#### `hypervisor` - -The `hypervisor` role discovers one target per Nova hypervisor node. The target -address defaults to the `host_ip` attribute of the hypervisor. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_openstack_hypervisor_host_ip`: the hypervisor node's IP address. -* `__meta_openstack_hypervisor_hostname`: the hypervisor node's name. -* `__meta_openstack_hypervisor_id`: the hypervisor node's ID. -* `__meta_openstack_hypervisor_state`: the hypervisor node's state. -* `__meta_openstack_hypervisor_status`: the hypervisor node's status. -* `__meta_openstack_hypervisor_type`: the hypervisor node's type. - -#### `instance` - -The `instance` role discovers one target per network interface of Nova -instance. The target address defaults to the private IP address of the network -interface. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_openstack_address_pool`: the pool of the private IP. -* `__meta_openstack_instance_flavor`: the flavor name of the OpenStack instance, or the flavor ID if the flavor name isn't available. -* `__meta_openstack_instance_id`: the OpenStack instance ID. -* `__meta_openstack_instance_image`: the ID of the image the OpenStack instance is using. -* `__meta_openstack_instance_name`: the OpenStack instance name. -* `__meta_openstack_instance_status`: the status of the OpenStack instance. -* `__meta_openstack_private_ip`: the private IP of the OpenStack instance. -* `__meta_openstack_project_id`: the project (tenant) owning this instance. -* `__meta_openstack_public_ip`: the public IP of the OpenStack instance. -* `__meta_openstack_tag_`: each metadata item of the instance, with any unsupported characters converted to an underscore. -* `__meta_openstack_user_id`: the user account owning the tenant. - -#### `loadbalancer` - -The `loadbalancer` role discovers one target per Octavia loadbalancer with a -`PROMETHEUS` listener. The target address defaults to the VIP address -of the load balancer. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_openstack_loadbalancer_availability_zone`: the availability zone of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_floating_ip`: the floating IP of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_id`: the OpenStack load balancer ID. -* `__meta_openstack_loadbalancer_name`: the OpenStack load balancer name. -* `__meta_openstack_loadbalancer_provider`: the Octavia provider of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_operating_status`: the operating status of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_provisioning_status`: the provisioning status of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_tags`: comma separated list of the OpenStack load balancer. -* `__meta_openstack_loadbalancer_vip`: the VIP of the OpenStack load balancer. -* `__meta_openstack_project_id`: the project (tenant) owning this load balancer. - -See below for the configuration options for OpenStack discovery: - -```yaml -# The information to access the OpenStack API. - -# The OpenStack role of entities that should be discovered. -role: - -# The OpenStack Region. -region: - -# identity_endpoint specifies the HTTP endpoint that is required to work with -# the Identity API of the appropriate version. While it's ultimately needed by -# all of the identity services, it will often be populated by a provider-level -# function. -[ identity_endpoint: ] - -# username is required if using Identity V2 API. Consult with your provider's -# control panel to discover your account's username. In Identity V3, either -# userid or a combination of username and domain_id or domain_name are needed. -[ username: ] -[ userid: ] - -# password for the Identity V2 and V3 APIs. Consult with your provider's -# control panel to discover your account's preferred method of authentication. -[ password: ] - -# At most one of domain_id and domain_name must be provided if using username -# with Identity V3. Otherwise, either are optional. -[ domain_name: ] -[ domain_id: ] - -# The project_id and project_name fields are optional for the Identity V2 API. -# Some providers allow you to specify a project_name instead of the project_id. -# Some require both. Your provider's authentication policies will determine -# how these fields influence authentication. -[ project_name: ] -[ project_id: ] - -# The application_credential_id or application_credential_name fields are -# required if using an application credential to authenticate. Some providers -# allow you to create an application credential to authenticate rather than a -# password. -[ application_credential_name: ] -[ application_credential_id: ] - -# The application_credential_secret field is required if using an application -# credential to authenticate. -[ application_credential_secret: ] - -# Whether the service discovery should list all instances for all projects. -# It is only relevant for the 'instance' role and usually requires admin permissions. -[ all_tenants: | default: false ] - -# Refresh interval to re-read the instance list. -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# The availability of the endpoint to connect to. Must be one of public, admin or internal. -[ availability: | default = "public" ] - -# TLS configuration. -tls_config: - [ ] -``` - -### `` - -OVHcloud SD configurations allow retrieving scrape targets from OVHcloud's [dedicated servers](https://www.ovhcloud.com/en/bare-metal/) and [VPS](https://www.ovhcloud.com/en/vps/) using -their [API](https://api.ovh.com/). -Prometheus will periodically check the REST endpoint and create a target for every discovered server. -The role will try to use the public IPv4 address as default address, if there's none it will try to use the IPv6 one. This may be changed with relabeling. -For OVHcloud's [public cloud instances](https://www.ovhcloud.com/en/public-cloud/) you can use the [openstack_sd_config](#openstack_sd_config). - -#### VPS - -* `__meta_ovhcloud_vps_cluster`: the cluster of the server -* `__meta_ovhcloud_vps_datacenter`: the datacenter of the server -* `__meta_ovhcloud_vps_disk`: the disk of the server -* `__meta_ovhcloud_vps_display_name`: the display name of the server -* `__meta_ovhcloud_vps_ipv4`: the IPv4 of the server -* `__meta_ovhcloud_vps_ipv6`: the IPv6 of the server -* `__meta_ovhcloud_vps_keymap`: the KVM keyboard layout of the server -* `__meta_ovhcloud_vps_maximum_additional_ip`: the maximum additional IPs of the server -* `__meta_ovhcloud_vps_memory_limit`: the memory limit of the server -* `__meta_ovhcloud_vps_memory`: the memory of the server -* `__meta_ovhcloud_vps_monitoring_ip_blocks`: the monitoring IP blocks of the server -* `__meta_ovhcloud_vps_name`: the name of the server -* `__meta_ovhcloud_vps_netboot_mode`: the netboot mode of the server -* `__meta_ovhcloud_vps_offer_type`: the offer type of the server -* `__meta_ovhcloud_vps_offer`: the offer of the server -* `__meta_ovhcloud_vps_state`: the state of the server -* `__meta_ovhcloud_vps_vcore`: the number of virtual cores of the server -* `__meta_ovhcloud_vps_version`: the version of the server -* `__meta_ovhcloud_vps_zone`: the zone of the server - -#### Dedicated servers - -* `__meta_ovhcloud_dedicated_server_commercial_range`: the commercial range of the server -* `__meta_ovhcloud_dedicated_server_datacenter`: the datacenter of the server -* `__meta_ovhcloud_dedicated_server_ipv4`: the IPv4 of the server -* `__meta_ovhcloud_dedicated_server_ipv6`: the IPv6 of the server -* `__meta_ovhcloud_dedicated_server_link_speed`: the link speed of the server -* `__meta_ovhcloud_dedicated_server_name`: the name of the server -* `__meta_ovhcloud_dedicated_server_no_intervention`: whether datacenter intervention is disabled for the server -* `__meta_ovhcloud_dedicated_server_os`: the operating system of the server -* `__meta_ovhcloud_dedicated_server_rack`: the rack of the server -* `__meta_ovhcloud_dedicated_server_reverse`: the reverse DNS name of the server -* `__meta_ovhcloud_dedicated_server_server_id`: the ID of the server -* `__meta_ovhcloud_dedicated_server_state`: the state of the server -* `__meta_ovhcloud_dedicated_server_support_level`: the support level of the server - -See below for the configuration options for OVHcloud discovery: - -```yaml -# Access key to use. https://api.ovh.com -application_key: -application_secret: -consumer_key: -# Service of the targets to retrieve. Must be `vps` or `dedicated_server`. -service: -# API endpoint. https://github.com/ovh/go-ovh#supported-apis -[ endpoint: | default = "ovh-eu" ] -# Refresh interval to re-read the resources list. -[ refresh_interval: | default = 60s ] -``` - -### `` - -PuppetDB SD configurations allow retrieving scrape targets from -[PuppetDB](https://puppet.com/docs/puppetdb/latest/index.html) resources. - -This SD discovers resources and will create a target for each resource returned -by the API. - -The resource address is the `certname` of the resource and can be changed during -[relabeling](#relabel_config). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_puppetdb_query`: the Puppet Query Language (PQL) query -* `__meta_puppetdb_certname`: the name of the node associated with the resource -* `__meta_puppetdb_resource`: a SHA-1 hash of the resource’s type, title, and parameters, for identification -* `__meta_puppetdb_type`: the resource type -* `__meta_puppetdb_title`: the resource title -* `__meta_puppetdb_exported`: whether the resource is exported (`"true"` or `"false"`) -* `__meta_puppetdb_tags`: comma separated list of resource tags -* `__meta_puppetdb_file`: the manifest file in which the resource was declared -* `__meta_puppetdb_environment`: the environment of the node associated with the resource -* `__meta_puppetdb_parameter_`: the parameters of the resource - - -See below for the configuration options for PuppetDB discovery: - -```yaml -# The URL of the PuppetDB root query endpoint. -url: - -# Puppet Query Language (PQL) query. Only resources are supported. -# https://puppet.com/docs/puppetdb/latest/api/query/v4/pql.html -query: - -# Whether to include the parameters as meta labels. -# Due to the differences between parameter types and Prometheus labels, -# some parameters might not be rendered. The format of the parameters might -# also change in future releases. -# -# Note: Enabling this exposes parameters in the Prometheus UI and API. Make sure -# that you don't have secrets exposed as parameters if you enable this. -[ include_parameters: | default = false ] - -# Refresh interval to re-read the resources list. -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -See [this example Prometheus configuration file](/documentation/examples/prometheus-puppetdb.yml) -for a detailed example of configuring Prometheus with PuppetDB. - - -### `` - -File-based service discovery provides a more generic way to configure static targets -and serves as an interface to plug in custom service discovery mechanisms. - -It reads a set of files containing a list of zero or more -``s. Changes to all defined files are detected via disk watches -and applied immediately. - -While those individual files are watched for changes, -the parent directory is also watched implicitly. This is to handle [atomic -renaming](https://github.com/fsnotify/fsnotify/blob/c1467c02fba575afdb5f4201072ab8403bbf00f4/README.md?plain=1#L128) efficiently and to detect new files that match the configured globs. -This may cause issues if the parent directory contains a large number of other files, -as each of these files will be watched too, even though the events related -to them are not relevant. - -Files may be provided in YAML or JSON format. Only -changes resulting in well-formed target groups are applied. - -Files must contain a list of static configs, using these formats: - -**JSON** - -```json -[ - { - "targets": [ "", ... ], - "labels": { - "": "", ... - } - }, - ... -] -``` - -**YAML** - -```yaml -- targets: - [ - '' ] - labels: - [ : ... ] -``` - -As a fallback, the file contents are also re-read periodically at the specified -refresh interval. - -Each target has a meta label `__meta_filepath` during the -[relabeling phase](#relabel_config). Its value is set to the -filepath from which the target was extracted. - -There is a list of -[integrations](https://prometheus.io/docs/operating/integrations/#file-service-discovery) with this -discovery mechanism. - -```yaml -# Patterns for files from which target groups are extracted. -files: - [ - ... ] - -# Refresh interval to re-read the files. -[ refresh_interval: | default = 5m ] -``` - -Where `` may be a path ending in `.json`, `.yml` or `.yaml`. The last path segment -may contain a single `*` that matches any character sequence, e.g. `my/path/tg_*.json`. - -### `` - -[GCE](https://cloud.google.com/compute/) SD configurations allow retrieving scrape targets from GCP GCE instances. -The private IP address is used by default, but may be changed to the public IP -address with relabeling. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_gce_instance_id`: the numeric id of the instance -* `__meta_gce_instance_name`: the name of the instance -* `__meta_gce_label_`: each GCE label of the instance, with any unsupported characters converted to an underscore -* `__meta_gce_machine_type`: full or partial URL of the machine type of the instance -* `__meta_gce_metadata_`: each metadata item of the instance -* `__meta_gce_network`: the network URL of the instance -* `__meta_gce_private_ip`: the private IP address of the instance -* `__meta_gce_interface_ipv4_`: IPv4 address of each named interface -* `__meta_gce_project`: the GCP project in which the instance is running -* `__meta_gce_public_ip`: the public IP address of the instance, if present -* `__meta_gce_subnetwork`: the subnetwork URL of the instance -* `__meta_gce_tags`: comma separated list of instance tags -* `__meta_gce_zone`: the GCE zone URL in which the instance is running - -See below for the configuration options for GCE discovery: - -```yaml -# The information to access the GCE API. - -# The GCP Project -project: - -# The zone of the scrape targets. If you need multiple zones use multiple -# gce_sd_configs. -zone: - -# Filter can be used optionally to filter the instance list by other criteria -# Syntax of this filter string is described here in the filter query parameter section: -# https://cloud.google.com/compute/docs/reference/latest/instances/list -[ filter: ] - -# Refresh interval to re-read the instance list -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# The tag separator is used to separate the tags on concatenation -[ tag_separator: | default = , ] -``` - -Credentials are discovered by the Google Cloud SDK default client by looking -in the following places, preferring the first location found: - -1. a JSON file specified by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable -2. a JSON file in the well-known path `$HOME/.config/gcloud/application_default_credentials.json` -3. fetched from the GCE metadata server - -If Prometheus is running within GCE, the service account associated with the -instance it is running on should have at least read-only permissions to the -compute resources. If running outside of GCE make sure to create an appropriate -service account and place the credential file in one of the expected locations. - -### `` - -Hetzner SD configurations allow retrieving scrape targets from -[Hetzner](https://www.hetzner.com/) [Cloud](https://www.hetzner.cloud/) API and -[Robot](https://docs.hetzner.com/robot/) API. -This service discovery uses the public IPv4 address by default, but that can be -changed with relabeling, as demonstrated in [the Prometheus hetzner-sd -configuration file](/documentation/examples/prometheus-hetzner.yml). - -The following meta labels are available on all targets during [relabeling](#relabel_config): - -* `__meta_hetzner_server_id`: the ID of the server -* `__meta_hetzner_server_name`: the name of the server -* `__meta_hetzner_server_status`: the status of the server -* `__meta_hetzner_public_ipv4`: the public ipv4 address of the server -* `__meta_hetzner_public_ipv6_network`: the public ipv6 network (/64) of the server - -Note that the `__meta_hetzner_datacenter` label is deprecated for both roles `robot` and `hcloud`: -- For the `robot` role, the replacement label is `__meta_hetzner_robot_datacenter`. -- For the `hcloud` role, the label will be removed after 1 July 2026. For more details, see the [changelog](https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters). - -The labels below are only available for targets with `role` set to `hcloud`: - -* `__meta_hetzner_hcloud_image_name`: the image name of the server -* `__meta_hetzner_hcloud_image_description`: the description of the server image -* `__meta_hetzner_hcloud_image_os_flavor`: the OS flavor of the server image -* `__meta_hetzner_hcloud_image_os_version`: the OS version of the server image -* `__meta_hetzner_hcloud_location`: the location of the server -* `__meta_hetzner_hcloud_location_network_zone`: the network zone of the server -* `__meta_hetzner_hcloud_datacenter_location`: the location of the server (deprecated in favor of `__meta_hetzner_hcloud_location`) -* `__meta_hetzner_hcloud_datacenter_location_network_zone`: the network zone of the server (deprecated in favor of `__meta_hetzner_hcloud_location_network_zone`) -* `__meta_hetzner_hcloud_server_type`: the type of the server -* `__meta_hetzner_hcloud_cpu_cores`: the CPU cores count of the server -* `__meta_hetzner_hcloud_cpu_type`: the CPU type of the server (shared or dedicated) -* `__meta_hetzner_hcloud_memory_size_gb`: the amount of memory of the server (in GB) -* `__meta_hetzner_hcloud_disk_size_gb`: the disk size of the server (in GB) -* `__meta_hetzner_hcloud_private_ipv4_`: the private ipv4 address of the server within a given network -* `__meta_hetzner_hcloud_label_`: each label of the server, with any unsupported characters converted to an underscore -* `__meta_hetzner_hcloud_labelpresent_`: `true` for each label of the server, with any unsupported characters converted to an underscore - -The labels below are only available for targets with `role` set to `robot`: - -* `__meta_hetzner_robot_datacenter`: the datacenter of the server -* `__meta_hetzner_robot_product`: the product of the server -* `__meta_hetzner_robot_cancelled`: the server cancellation status - -```yaml -# The Hetzner role of entities that should be discovered. -# One of robot or hcloud. -role: - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# The time after which the servers are refreshed. -[ refresh_interval: | default = 60s ] - -# Label selector used to filter the servers when fetching them from the API. See https://docs.hetzner.cloud/#label-selector for more details. -# Only used when role is hcloud. -[ label_selector: ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -HTTP-based service discovery provides a more generic way to configure static targets -and serves as an interface to plug in custom service discovery mechanisms. - -It fetches targets from an HTTP endpoint containing a list of zero or more -``s. The target must reply with an HTTP 200 response. -The HTTP header `Content-Type` must be `application/json`, and the body must be -valid JSON. - -Example response body: - -```json -[ - { - "targets": [ "", ... ], - "labels": { - "": "", ... - } - }, - ... -] -``` - -The endpoint is queried periodically at the specified refresh interval. -The `prometheus_sd_http_failures_total` counter metric tracks the number of -refresh failures. - -Each target has a meta label `__meta_url` during the -[relabeling phase](#relabel_config). Its value is set to the -URL from which the target was extracted. - -There is a list of -[integrations](https://prometheus.io/docs/operating/integrations/#http-service-discovery) with this -discovery mechanism. - -```yaml -# URL from which the targets are fetched. -url: - -# Refresh interval to re-query the endpoint. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -IONOS SD configurations allows retrieving scrape targets from -[IONOS Cloud](https://cloud.ionos.com/) API. This service discovery uses the -first NICs IP address by default, but that can be changed with relabeling. The -following meta labels are available on all targets during -[relabeling](#relabel_config): - -* `__meta_ionos_server_availability_zone`: the availability zone of the server -* `__meta_ionos_server_boot_cdrom_id`: the ID of the CD-ROM the server is booted - from -* `__meta_ionos_server_boot_image_id`: the ID of the boot image or snapshot the - server is booted from -* `__meta_ionos_server_boot_volume_id`: the ID of the boot volume -* `__meta_ionos_server_cpu_family`: the CPU family of the server - to -* `__meta_ionos_server_id`: the ID of the server -* `__meta_ionos_server_ip`: comma separated list of all IPs assigned to the - server -* `__meta_ionos_server_lifecycle`: the lifecycle state of the server resource -* `__meta_ionos_server_name`: the name of the server -* `__meta_ionos_server_nic_ip_`: comma separated list of IPs, grouped - by the name of each NIC attached to the server -* `__meta_ionos_server_servers_id`: the ID of the servers the server belongs to -* `__meta_ionos_server_state`: the execution state of the server -* `__meta_ionos_server_type`: the type of the server - -```yaml -# The unique ID of the data center. -datacenter_id: - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# The time after which the servers are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Kubernetes SD configurations allow retrieving scrape targets from -[Kubernetes'](https://kubernetes.io/) REST API and always staying synchronized with -the cluster state. - -One of the following `role` types can be configured to discover targets: - -#### `node` - -The `node` role discovers one target per cluster node with the address defaulting -to the Kubelet's HTTP port. -The target address defaults to the first existing address of the Kubernetes -node object in the address type order of `NodeInternalIP`, `NodeExternalIP`, -`NodeLegacyHostIP`, and `NodeHostName`. - -Available meta labels: - -* `__meta_kubernetes_node_name`: The name of the node object. -* `__meta_kubernetes_node_provider_id`: The cloud provider's name for the node object. -* `__meta_kubernetes_node_condition_`: For every entry in node.Status.Conditions, a label with the condition type in lowercase. Possible values are `true`, `false`, or `unknown`. Examples: `__meta_kubernetes_node_condition_ready`, `__meta_kubernetes_node_condition_memorypressure`, `__meta_kubernetes_node_condition_diskpressure`. -* `__meta_kubernetes_node_label_`: Each label from the node object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_node_labelpresent_`: `true` for each label from the node object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_node_annotation_`: Each annotation from the node object. -* `__meta_kubernetes_node_annotationpresent_`: `true` for each annotation from the node object. -* `__meta_kubernetes_node_address_`: The first address for each node address type, if it exists. - -In addition, the `instance` label for the node will be set to the node name -as retrieved from the API server. - -#### `service` - -The `service` role discovers a target for each service port for each service. -This is generally useful for blackbox monitoring of a service. -The address will be set to the Kubernetes DNS name of the service and respective -service port. - -Available meta labels: - -* `__meta_kubernetes_namespace`: The namespace of the service object. -* `__meta_kubernetes_service_annotation_`: Each annotation from the service object. -* `__meta_kubernetes_service_annotationpresent_`: "true" for each annotation of the service object. -* `__meta_kubernetes_service_cluster_ip`: The cluster IP address of the service. (Does not apply to services of type ExternalName) -* `__meta_kubernetes_service_loadbalancer_ip`: The IP address of the loadbalancer. (Applies to services of type LoadBalancer) -* `__meta_kubernetes_service_external_name`: The DNS name of the service. (Applies to services of type ExternalName) -* `__meta_kubernetes_service_label_`: Each label from the service object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_service_labelpresent_`: `true` for each label of the service object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_service_name`: The name of the service object. -* `__meta_kubernetes_service_port_name`: Name of the service port for the target. -* `__meta_kubernetes_service_port_number`: Number of the service port for the target. -* `__meta_kubernetes_service_port_protocol`: Protocol of the service port for the target. -* `__meta_kubernetes_service_type`: The type of the service. - -#### `pod` - -The `pod` role discovers all pods and exposes their containers as targets. For each declared -port of a container, a single target is generated. If a container has no specified ports, -a port-free target per container is created for manually adding a port via relabeling. - -Available meta labels: - -* `__meta_kubernetes_namespace`: The namespace of the pod object. -* `__meta_kubernetes_pod_name`: The name of the pod object. -* `__meta_kubernetes_pod_ip`: The pod IP of the pod object. -* `__meta_kubernetes_pod_label_`: Each label from the pod object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_pod_labelpresent_`: `true` for each label from the pod object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_pod_annotation_`: Each annotation from the pod object. -* `__meta_kubernetes_pod_annotationpresent_`: `true` for each annotation from the pod object. -* `__meta_kubernetes_pod_container_init`: `true` if the container is an [InitContainer](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) -* `__meta_kubernetes_pod_container_name`: Name of the container the target address points to. -* `__meta_kubernetes_pod_container_id`: ID of the container the target address points to. The ID is in the form `://`. -* `__meta_kubernetes_pod_container_image`: The image the container is using. -* `__meta_kubernetes_pod_container_port_name`: Name of the container port. -* `__meta_kubernetes_pod_container_port_number`: Number of the container port. -* `__meta_kubernetes_pod_container_port_protocol`: Protocol of the container port. -* `__meta_kubernetes_pod_ready`: Set to `true` or `false` for the pod's ready state. -* `__meta_kubernetes_pod_phase`: Set to `Pending`, `Running`, `Succeeded`, `Failed` or `Unknown` - in the [lifecycle](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase). -* `__meta_kubernetes_pod_node_name`: The name of the node the pod is scheduled onto. -* `__meta_kubernetes_pod_host_ip`: The current host IP of the pod object. -* `__meta_kubernetes_pod_uid`: The UID of the pod object. -* `__meta_kubernetes_pod_controller_kind`: Object kind of the pod controller. -* `__meta_kubernetes_pod_controller_name`: Name of the pod controller. -* `__meta_kubernetes_pod_deployment_name`: Name of the deployment the pod belongs to. Requires `attach_metadata: {deployment: true}`. -* `__meta_kubernetes_pod_cronjob_name`: Name of the cronjob the pod belongs to. Requires `attach_metadata: {cronjob: true}`. -* `__meta_kubernetes_pod_job_name`: Name of the job the pod belongs to. Requires `attach_metadata: {job: true}`. - -#### `endpoints` - -The `endpoints` role discovers targets from listed endpoints of a service. For each endpoint -address one target is discovered per port. If the endpoint is backed by a pod, all -additional container ports of the pod, not bound to an endpoint port, are discovered as targets as well. - -Note that the Endpoints API is [deprecated in Kubernetes v1.33+](https://kubernetes.io/blog/2025/04/24/endpoints-deprecation/), -it is recommended to use EndpointSlices instead and switch to the `endpointslice` role below. - -Available meta labels: - -* `__meta_kubernetes_namespace`: The namespace of the endpoints object. -* `__meta_kubernetes_endpoints_name`: The names of the endpoints object. -* `__meta_kubernetes_endpoints_label_`: Each label from the endpoints object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_endpoints_labelpresent_`: `true` for each label from the endpoints object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_endpoints_annotation_`: Each annotation from the endpoints object. -* `__meta_kubernetes_endpoints_annotationpresent_`: `true` for each annotation from the endpoints object. -* For all targets discovered directly from the endpoints list (those not additionally inferred - from underlying pods), the following labels are attached: - * `__meta_kubernetes_endpoint_hostname`: Hostname of the endpoint. - * `__meta_kubernetes_endpoint_node_name`: Name of the node hosting the endpoint. - * `__meta_kubernetes_endpoint_ready`: Set to `true` or `false` for the endpoint's ready state. - * `__meta_kubernetes_endpoint_port_name`: Name of the endpoint port. - * `__meta_kubernetes_endpoint_port_protocol`: Protocol of the endpoint port. - * `__meta_kubernetes_endpoint_address_target_kind`: Kind of the endpoint address target. - * `__meta_kubernetes_endpoint_address_target_name`: Name of the endpoint address target. -* If the endpoints belong to a service, all labels of the `role: service` discovery are attached. -* For all targets backed by a pod, all labels of the `role: pod` discovery are attached. - -#### `endpointslice` - -The `endpointslice` role discovers targets from existing endpointslices. For each endpoint -address referenced in the endpointslice object one target is discovered. If the endpoint is backed by a pod, all -additional container ports of the pod, not bound to an endpoint port, are discovered as targets as well. - -The role requires the `discovery.k8s.io/v1` API version (available since Kubernetes v1.21). - -Available meta labels: - -* `__meta_kubernetes_namespace`: The namespace of the endpointslice object. -* `__meta_kubernetes_endpointslice_name`: The name of endpointslice object. -* `__meta_kubernetes_endpointslice_label_`: Each label from the endpointslice object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_endpointslice_labelpresent_`: `true` for each label from the endpointslice object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_endpointslice_annotation_`: Each annotation from the endpointslice object. -* `__meta_kubernetes_endpointslice_annotationpresent_`: `true` for each annotation from the endpointslice object. -* For all targets discovered directly from the endpointslice list (those not additionally inferred - from underlying pods), the following labels are attached: - * `__meta_kubernetes_endpointslice_address_target_kind`: Kind of the referenced object. - * `__meta_kubernetes_endpointslice_address_target_name`: Name of referenced object. - * `__meta_kubernetes_endpointslice_address_type`: The ip protocol family of the address of the target. - * `__meta_kubernetes_endpointslice_endpoint_conditions_ready`: Set to `true` or `false` for the referenced endpoint's ready state. - * `__meta_kubernetes_endpointslice_endpoint_conditions_serving`: Set to `true` or `false` for the referenced endpoint's serving state. - * `__meta_kubernetes_endpointslice_endpoint_conditions_terminating`: Set to `true` or `false` for the referenced endpoint's terminating state. - * `__meta_kubernetes_endpointslice_endpoint_topology_kubernetes_io_hostname`: Name of the node hosting the referenced endpoint. - * `__meta_kubernetes_endpointslice_endpoint_topology_present_kubernetes_io_hostname`: Flag that shows if the referenced object has a kubernetes.io/hostname annotation. - * `__meta_kubernetes_endpointslice_endpoint_hostname`: Hostname of the referenced endpoint. - * `__meta_kubernetes_endpointslice_endpoint_node_name`: Name of the Node hosting the referenced endpoint. - * `__meta_kubernetes_endpointslice_endpoint_zone`: Zone the referenced endpoint exists in. - * `__meta_kubernetes_endpointslice_port`: Port of the referenced endpoint. - * `__meta_kubernetes_endpointslice_port_name`: Named port of the referenced endpoint. - * `__meta_kubernetes_endpointslice_port_protocol`: Protocol of the referenced endpoint. -* If the endpoints belong to a service, all labels of the `role: service` discovery are attached. -* For all targets backed by a pod, all labels of the `role: pod` discovery are attached. - -#### `ingress` - -The `ingress` role discovers a target for each path of each ingress. -This is generally useful for blackbox monitoring of an ingress. -The address will be set to the host specified in the ingress spec. - -The role requires the `networking.k8s.io/v1` API version (available since Kubernetes v1.19). - -Available meta labels: - -* `__meta_kubernetes_namespace`: The namespace of the ingress object. -* `__meta_kubernetes_ingress_name`: The name of the ingress object. -* `__meta_kubernetes_ingress_label_`: Each label from the ingress object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_ingress_labelpresent_`: `true` for each label from the ingress object, with any unsupported characters converted to an underscore. -* `__meta_kubernetes_ingress_annotation_`: Each annotation from the ingress object. -* `__meta_kubernetes_ingress_annotationpresent_`: `true` for each annotation from the ingress object. -* `__meta_kubernetes_ingress_class_name`: Class name from ingress spec, if present. -* `__meta_kubernetes_ingress_scheme`: Protocol scheme of ingress, `https` if TLS - config is set. Defaults to `http`. -* `__meta_kubernetes_ingress_path`: Path from ingress spec. Defaults to `/`. - -See below for the configuration options for Kubernetes discovery: - -```yaml -# The information to access the Kubernetes API. - -# The API server addresses. If left empty, Prometheus is assumed to run inside -# of the cluster and will discover API servers automatically and use the pod's -# CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/. -[ api_server: ] - -# The Kubernetes role of entities that should be discovered. -# One of endpoints, endpointslice, service, pod, node, or ingress. -role: - -# Optional path to a kubeconfig file. -# Note that api_server and kube_config are mutually exclusive. -[ kubeconfig_file: ] - -# Optional namespace discovery. If omitted, all namespaces are used. -namespaces: - own_namespace: - names: - [ - ] - -# Optional label and field selectors to limit the discovery process to a subset of available resources. -# See https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/ -# and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ to learn more about the possible -# filters that can be used. The endpoints role supports pod, service and endpoints selectors. -# The pod role supports node selectors when configured with `attach_metadata: {node: true}`. -# Other roles only support selectors matching the role itself (e.g. node role can only contain node selectors). - -# Note: When making decision about using field/label selector make sure that this -# is the best approach - it will prevent Prometheus from reusing single list/watch -# for all scrape configs. This might result in a bigger load on the Kubernetes API, -# because per each selector combination there will be additional LIST/WATCH. On the other hand, -# if you just want to monitor small subset of pods in large cluster it's recommended to use selectors. -# Decision, if selectors should be used or not depends on the particular situation. -[ selectors: - [ - role: - [ label: ] - [ field: ] ]] - -# Optional metadata to attach to discovered targets. If omitted, no additional metadata is attached. -attach_metadata: -# Attaches node metadata to discovered targets. Valid for roles: pod, endpoints, endpointslice. -# When set to true, Prometheus must have permissions to list/watch Nodes. - [ node: | default = false ] -# Attaches namespace metadata to discovered targets. Valid for roles: pod, endpoints, endpointslice, service, ingress. -# When set to true, Prometheus must have permissions to list/watch Namespaces. - [ namespace: | default = false ] -# Attaches deployment metadata to discovered pod targets. Valid for role: pod. -# When set to true, Prometheus must have permissions to list/watch ReplicaSets. -# Enables the __meta_kubernetes_pod_deployment_name label. - [ deployment: | default = false ] -# Attaches job metadata to discovered pod targets. Valid for role: pod. -# When set to true, Prometheus must have permissions to list/watch Jobs. -# Enables the __meta_kubernetes_pod_job_name label. - [ job: | default = false ] -# Attaches cronjob metadata to discovered pod targets. Valid for role: pod. -# When set to true, Prometheus must have permissions to list/watch Jobs. -# Enables the __meta_kubernetes_pod_cronjob_name label. - [ cronjob: | default = false ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -See [this example Prometheus configuration file](/documentation/examples/prometheus-kubernetes.yml) -for a detailed example of configuring Prometheus for Kubernetes. - -You may wish to check out the 3rd party [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator), -which automates the Prometheus setup on top of Kubernetes. - -### `` - -Kuma SD configurations allow retrieving scrape target from the [Kuma](https://kuma.io) control plane. - -This SD discovers "monitoring assignments" based on Kuma [Dataplane Proxies](https://kuma.io/docs/latest/production/dp-config/dpp/#data-plane-proxy), -via the MADS v1 (Monitoring Assignment Discovery Service) xDS API, and will create a target for each proxy -inside a Prometheus-enabled mesh. - -The following meta labels are available for each target: - -* `__meta_kuma_mesh`: the name of the proxy's Mesh -* `__meta_kuma_dataplane`: the name of the proxy -* `__meta_kuma_service`: the name of the proxy's associated Service -* `__meta_kuma_label_`: each tag of the proxy - -See below for the configuration options for Kuma MonitoringAssignment discovery: - -```yaml -# Address of the Kuma Control Plane's MADS xDS server. -server: - -# Client id is used by Kuma Control Plane to compute Monitoring Assignment for specific Prometheus backend. -# This is useful when migrating between multiple Prometheus backends, or having separate backend for each Mesh. -# When not specified, system hostname/fqdn will be used if available, if not `prometheus` will be used. -[ client_id: ] - -# The time to wait between polling update requests. -[ refresh_interval: | default = 30s ] - -# The time after which the monitoring assignments are refreshed. -[ fetch_timeout: | default = 2m ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -The [relabeling phase](#relabel_config) is the preferred and more powerful way -to filter proxies and user-defined tags. - -### `` - -Lightsail SD configurations allow retrieving scrape targets from [AWS Lightsail](https://aws.amazon.com/lightsail/) -instances. The private IP address is used by default, but may be changed to -the public IP address with relabeling. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_lightsail_availability_zone`: the availability zone in which the instance is running -* `__meta_lightsail_blueprint_id`: the Lightsail blueprint ID -* `__meta_lightsail_bundle_id`: the Lightsail bundle ID -* `__meta_lightsail_instance_name`: the name of the Lightsail instance -* `__meta_lightsail_instance_state`: the state of the Lightsail instance -* `__meta_lightsail_instance_support_code`: the support code of the Lightsail instance -* `__meta_lightsail_ipv6_addresses`: comma separated list of IPv6 addresses assigned to the instance's network interfaces, if present -* `__meta_lightsail_private_ip`: the private IP address of the instance -* `__meta_lightsail_public_ip`: the public IP address of the instance, if available -* `__meta_lightsail_region`: the region of the instance -* `__meta_lightsail_tag_`: each tag value of the instance - -See below for the configuration options for Lightsail discovery: - -```yaml -# The information to access the Lightsail API. - -# The AWS region. If blank, the region from the instance metadata is used. -[ region: ] - -# Custom endpoint to be used. -[ endpoint: ] - -# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID` -# and `AWS_SECRET_ACCESS_KEY` are used. -[ access_key: ] -[ secret_key: ] -# Named AWS profile used to connect to the API. -[ profile: ] - -# AWS Role ARN, an alternative to using AWS API keys. -[ role_arn: ] - -# Optional External ID that can go along with role_arn. -[ external_id: ] - -# Refresh interval to re-read the instance list. -[ refresh_interval: | default = 60s ] - -# The port to scrape metrics from. If using the public IP address, this must -# instead be specified in the relabeling rule. -[ port: | default = 80 ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Linode SD configurations allow retrieving scrape targets from [Linode's](https://www.linode.com/) -Linode APIv4. -This service discovery uses the public IPv4 address by default, by that can be -changed with relabeling, as demonstrated in [the Prometheus linode-sd -configuration file](/documentation/examples/prometheus-linode.yml). - -Linode APIv4 Token must be created with scopes: `linodes:read_only`, `ips:read_only`, and `events:read_only`. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_linode_instance_id`: the id of the linode instance -* `__meta_linode_instance_label`: the label of the linode instance -* `__meta_linode_image`: the slug of the linode instance's image -* `__meta_linode_private_ipv4`: the private IPv4 of the linode instance -* `__meta_linode_public_ipv4`: the public IPv4 of the linode instance -* `__meta_linode_public_ipv6`: the public IPv6 of the linode instance -* `__meta_linode_private_ipv4_rdns`: the reverse DNS for the first private IPv4 of the linode instance -* `__meta_linode_public_ipv4_rdns`: the reverse DNS for the first public IPv4 of the linode instance -* `__meta_linode_public_ipv6_rdns`: the reverse DNS for the first public IPv6 of the linode instance -* `__meta_linode_region`: the region of the linode instance -* `__meta_linode_type`: the type of the linode instance -* `__meta_linode_status`: the status of the linode instance -* `__meta_linode_tags`: a list of tags of the linode instance joined by the tag separator -* `__meta_linode_group`: the display group a linode instance is a member of -* `__meta_linode_gpus`: the number of GPU's of the linode instance -* `__meta_linode_hypervisor`: the virtualization software powering the linode instance -* `__meta_linode_backups`: the backup service status of the linode instance -* `__meta_linode_specs_disk_bytes`: the amount of storage space the linode instance has access to -* `__meta_linode_specs_memory_bytes`: the amount of RAM the linode instance has access to -* `__meta_linode_specs_vcpus`: the number of VCPUS this linode has access to -* `__meta_linode_specs_transfer_bytes`: the amount of network transfer the linode instance is allotted each month -* `__meta_linode_extra_ips`: a list of all extra IPv4 addresses assigned to the linode instance joined by the tag separator -* `__meta_linode_ipv6_ranges`: a list of IPv6 ranges with mask assigned to the linode instance joined by the tag separator - -```yaml - -# Optional region to filter on. -[ region: ] - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# The string by which Linode Instance tags are joined into the tag label. -[ tag_separator: | default = , ] - -# The time after which the linode instances are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Marathon SD configurations allow retrieving scrape targets using the -[Marathon](https://mesosphere.github.io/marathon/) REST API. Prometheus -will periodically check the REST endpoint for currently running tasks and -create a target group for every app that has at least one healthy task. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_marathon_app`: the name of the app (with slashes replaced by dashes) -* `__meta_marathon_image`: the name of the Docker image used (if available) -* `__meta_marathon_task`: the ID of the Mesos task -* `__meta_marathon_app_label_`: any Marathon labels attached to the app, with any unsupported characters converted to an underscore -* `__meta_marathon_port_definition_label_`: the port definition labels, with any unsupported characters converted to an underscore -* `__meta_marathon_port_mapping_label_`: the port mapping labels, with any unsupported characters converted to an underscore -* `__meta_marathon_port_index`: the port index number (e.g. `1` for `PORT1`) - -See below for the configuration options for Marathon discovery: - -```yaml -# List of URLs to be used to contact Marathon servers. -# You need to provide at least one server URL. -servers: - - - -# Polling interval -[ refresh_interval: | default = 30s ] - -# Optional authentication information for token-based authentication -# https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token -# It is mutually exclusive with `auth_token_file` and other authentication mechanisms. -[ auth_token: ] - -# Optional authentication information for token-based authentication -# https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token -# It is mutually exclusive with `auth_token` and other authentication mechanisms. -[ auth_token_file: ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -By default every app listed in Marathon will be scraped by Prometheus. If not all -of your services provide Prometheus metrics, you can use a Marathon label and -Prometheus relabeling to control which instances will actually be scraped. -See [the Prometheus marathon-sd configuration file](/documentation/examples/prometheus-marathon.yml) -for a practical example on how to set up your Marathon app and your Prometheus -configuration. - -By default, all apps will show up as a single job in Prometheus (the one specified -in the configuration file), which can also be changed using relabeling. - -### `` - -Nerve SD configurations allow retrieving scrape targets from [AirBnB's Nerve](https://github.com/airbnb/nerve) which are stored in -[Zookeeper](https://zookeeper.apache.org/). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_nerve_path`: the full path to the endpoint node in Zookeeper -* `__meta_nerve_endpoint_host`: the host of the endpoint -* `__meta_nerve_endpoint_port`: the port of the endpoint -* `__meta_nerve_endpoint_name`: the name of the endpoint - -```yaml -# The Zookeeper servers. -servers: - - -# Paths can point to a single service, or the root of a tree of services. -paths: - - -[ timeout: | default = 10s ] -``` -### `` - -Nomad SD configurations allow retrieving scrape targets from [Nomad's](https://www.nomadproject.io/) -Service API. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_nomad_address`: the service address of the target -* `__meta_nomad_dc`: the datacenter name for the target -* `__meta_nomad_namespace`: the namespace of the target -* `__meta_nomad_node_id`: the node name defined for the target -* `__meta_nomad_service`: the name of the service the target belongs to -* `__meta_nomad_service_address`: the service address of the target -* `__meta_nomad_service_id`: the service ID of the target -* `__meta_nomad_service_port`: the service port of the target -* `__meta_nomad_tags`: the list of tags of the target joined by the tag separator - -```yaml -# The information to access the Nomad API. It is to be defined -# as the Nomad documentation requires. -[ allow_stale: | default = true ] -[ namespace: | default = default ] -[ refresh_interval: | default = 60s ] -[ region: | default = global ] -# The URL to connect to the API. -[ server: ] -[ tag_separator: | default = ,] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Serverset SD configurations allow retrieving scrape targets from [Serversets](https://github.com/twitter/finagle/tree/develop/finagle-serversets) which are -stored in [Zookeeper](https://zookeeper.apache.org/). Serversets are commonly -used by [Finagle](https://twitter.github.io/finagle/) and -[Aurora](https://aurora.apache.org/). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_serverset_path`: the full path to the serverset member node in Zookeeper -* `__meta_serverset_endpoint_host`: the host of the default endpoint -* `__meta_serverset_endpoint_port`: the port of the default endpoint -* `__meta_serverset_endpoint_host_`: the host of the given endpoint -* `__meta_serverset_endpoint_port_`: the port of the given endpoint -* `__meta_serverset_shard`: the shard number of the member -* `__meta_serverset_status`: the status of the member - -```yaml -# The Zookeeper servers. -servers: - - -# Paths can point to a single serverset, or the root of a tree of serversets. -paths: - - -[ timeout: | default = 10s ] -``` - -Serverset data must be in the JSON format, the Thrift format is not currently supported. - -### `` - -[STACKIT](https://www.stackit.de/de/) SD configurations allow retrieving -scrape targets from various APIs. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_stackit_availability_zone`: The availability zone of the server. -* `__meta_stackit_label_`: Each server label, with unsupported characters replaced by underscores. -* `__meta_stackit_labelpresent_`: "true" for each label of the server, with unsupported characters replaced by underscores. -* `__meta_stackit_private_ipv4_`: the private ipv4 address of the server within a given network -* `__meta_stackit_public_ipv4`: the public ipv4 address of the server -* `__meta_stackit_id`: The ID of the target. -* `__meta_stackit_type`: The type or brand of the target. -* `__meta_stackit_name`: The server name. -* `__meta_stackit_status`: The current status of the server. -* `__meta_stackit_power_status`: The power status of the server. - -See below for the configuration options for STACKIT discovery: - -```yaml -# The STACKIT project -project: - -# STACKIT region to use. No automatic discovery of the region is done. -[ region : | default = "eu01" ] - -# Custom API endpoint to be used. Format scheme://host:port -[ endpoint : ] - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# Raw private key string used for authenticating a service account -[ private_key: ] - -# Path to a file containing the raw private key string -[ private_key_path: ] - -# Full JSON-formatted service account key used for authentication -[ service_account_key: ] - -# Path to a file containing the JSON-formatted service account key -[ service_account_key_path: ] - -# Path to a file containing STACKIT credentials. -[ credentials_file_path: ] - -# The time after which the servers are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -A [Service Account Key](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-keys/) can be set through `http_config`. This can be done mapping values from STACKIT Service Account json into oauth2 configuration. - -From a given Service Account json -```json -{ - //.... - "credentials": { - "kid": "6a7c3b36-xxxxxxxx", - "iss": "xxxx@sa.stackit.cloud", - "sub": "af2c2336-xxxxxxxx", - "aud": "https://stackit-service-account-prod.apps.01.cf.eu01.stackit.cloud", - "privateKey": "-----BEGIN PRIVATE KEY-----xxxx" - } -} -``` - -properties can be mapped as: - -```yaml -stackit_sd_config: -- oauth2: - client_id: - client_certificate_key: - client_certificate_key_id: - iss: - audience: - grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer" - token_url: "https://service-account.api.stackit.cloud/token" - signature_algorithm: RS512 -``` - -### `` - -[Triton](https://github.com/joyent/triton) SD configurations allow retrieving -scrape targets from [Container Monitor](https://github.com/joyent/rfd/blob/master/rfd/0027/README.md) -discovery endpoints. - -One of the following `` types can be configured to discover targets: - -#### `container` - -The `container` role discovers one target per "virtual machine" owned by the `account`. -These are SmartOS zones or lx/KVM/bhyve branded zones. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_triton_groups`: the list of groups belonging to the target joined by a comma separator -* `__meta_triton_machine_alias`: the alias of the target container -* `__meta_triton_machine_brand`: the brand of the target container -* `__meta_triton_machine_id`: the UUID of the target container -* `__meta_triton_machine_image`: the target container's image type -* `__meta_triton_server_id`: the server UUID the target container is running on - -#### `cn` - -The `cn` role discovers one target for per compute node (also known as "server" or "global zone") making up the Triton infrastructure. -The `account` must be a Triton operator and is currently required to own at least one `container`. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_triton_machine_alias`: the hostname of the target (requires triton-cmon 1.7.0 or newer) -* `__meta_triton_machine_id`: the UUID of the target - -See below for the configuration options for Triton discovery: - -```yaml -# The information to access the Triton discovery API. - -# The account to use for discovering new targets. -account: - -# The type of targets to discover, can be set to: -# * "container" to discover virtual machines (SmartOS zones, lx/KVM/bhyve branded zones) running on Triton -# * "cn" to discover compute nodes (servers/global zones) making up the Triton infrastructure -[ role : | default = "container" ] - -# The DNS suffix which should be applied to target. -dns_suffix: - -# The Triton discovery endpoint (e.g. 'cmon.us-east-3b.triton.zone'). This is -# often the same value as dns_suffix. -endpoint: - -# A list of groups for which targets are retrieved, only supported when `role` == `container`. -# If omitted all containers owned by the requesting account are scraped. -groups: - [ - ... ] - -# The port to use for discovery and metric scraping. -[ port: | default = 9163 ] - -# The interval which should be used for refreshing targets. -[ refresh_interval: | default = 60s ] - -# The Triton discovery API version. -[ version: | default = 1 ] - -# TLS configuration. -tls_config: - [ ] -``` - -### `` - -Eureka SD configurations allow retrieving scrape targets using the -[Eureka](https://github.com/Netflix/eureka) REST API. Prometheus -will periodically check the REST endpoint and -create a target for every app instance. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_eureka_app_name`: the name of the app -* `__meta_eureka_app_instance_id`: the ID of the app instance -* `__meta_eureka_app_instance_hostname`: the hostname of the instance -* `__meta_eureka_app_instance_homepage_url`: the homepage url of the app instance -* `__meta_eureka_app_instance_statuspage_url`: the status page url of the app instance -* `__meta_eureka_app_instance_healthcheck_url`: the health check url of the app instance -* `__meta_eureka_app_instance_ip_addr`: the IP address of the app instance -* `__meta_eureka_app_instance_vip_address`: the VIP address of the app instance -* `__meta_eureka_app_instance_secure_vip_address`: the secure VIP address of the app instance -* `__meta_eureka_app_instance_status`: the status of the app instance -* `__meta_eureka_app_instance_port`: the port of the app instance -* `__meta_eureka_app_instance_port_enabled`: the port enabled of the app instance -* `__meta_eureka_app_instance_secure_port`: the secure port address of the app instance -* `__meta_eureka_app_instance_secure_port_enabled`: the secure port of the app instance -* `__meta_eureka_app_instance_country_id`: the country ID of the app instance -* `__meta_eureka_app_instance_metadata_`: app instance metadata -* `__meta_eureka_app_instance_datacenterinfo_name`: the datacenter name of the app instance -* `__meta_eureka_app_instance_datacenterinfo_`: the datacenter metadata - -See below for the configuration options for Eureka discovery: - -```yaml -# The URL to connect to the Eureka server. -server: - -# Refresh interval to re-read the app instance list. -[ refresh_interval: | default = 30s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -See [the Prometheus eureka-sd configuration file](/documentation/examples/prometheus-eureka.yml) -for a practical example on how to set up your Eureka app and your Prometheus -configuration. - -### `` - -Scaleway SD configurations allow retrieving scrape targets from [Scaleway instances](https://www.scaleway.com/en/virtual-instances/) and [baremetal services](https://www.scaleway.com/en/bare-metal-servers/). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -#### Instance role - - -* `__meta_scaleway_instance_boot_type`: the boot type of the server -* `__meta_scaleway_instance_hostname`: the hostname of the server -* `__meta_scaleway_instance_id`: the ID of the server -* `__meta_scaleway_instance_image_arch`: the arch of the server image -* `__meta_scaleway_instance_image_id`: the ID of the server image -* `__meta_scaleway_instance_image_name`: the name of the server image -* `__meta_scaleway_instance_location_cluster_id`: the cluster ID of the server location -* `__meta_scaleway_instance_location_hypervisor_id`: the hypervisor ID of the server location -* `__meta_scaleway_instance_location_node_id`: the node ID of the server location -* `__meta_scaleway_instance_name`: name of the server -* `__meta_scaleway_instance_organization_id`: the organization of the server -* `__meta_scaleway_instance_private_ipv4`: the private IPv4 address of the server -* `__meta_scaleway_instance_project_id`: project id of the server -* `__meta_scaleway_instance_public_ipv4`: the public IPv4 address of the server -* `__meta_scaleway_instance_public_ipv6`: the public IPv6 address of the server -* `__meta_scaleway_instance_public_ipv4_addresses`: the public IPv4 addresses of the server -* `__meta_scaleway_instance_public_ipv6_addresses`: the public IPv6 addresses of the server -* `__meta_scaleway_instance_region`: the region of the server -* `__meta_scaleway_instance_security_group_id`: the ID of the security group of the server -* `__meta_scaleway_instance_security_group_name`: the name of the security group of the server -* `__meta_scaleway_instance_status`: status of the server -* `__meta_scaleway_instance_tags`: the list of tags of the server joined by the tag separator -* `__meta_scaleway_instance_type`: commercial type of the server -* `__meta_scaleway_instance_zone`: the zone of the server (ex: `fr-par-1`, complete list [here](https://developers.scaleway.com/en/products/instance/api/#introduction)) - -This role uses the first address it finds in the following order: private IPv4, public IPv4, public IPv6. This can be -changed with relabeling, as demonstrated in [the Prometheus scaleway-sd -configuration file](/documentation/examples/prometheus-scaleway.yml). -Should an instance have no address before relabeling, it will not be added to the target list and you will not be able to relabel it. - -#### Baremetal role - -* `__meta_scaleway_baremetal_id`: the ID of the server -* `__meta_scaleway_baremetal_public_ipv4`: the public IPv4 address of the server -* `__meta_scaleway_baremetal_public_ipv6`: the public IPv6 address of the server -* `__meta_scaleway_baremetal_name`: the name of the server -* `__meta_scaleway_baremetal_os_name`: the name of the operating system of the server -* `__meta_scaleway_baremetal_os_version`: the version of the operating system of the server -* `__meta_scaleway_baremetal_project_id`: the project ID of the server -* `__meta_scaleway_baremetal_status`: the status of the server -* `__meta_scaleway_baremetal_tags`: the list of tags of the server joined by the tag separator -* `__meta_scaleway_baremetal_type`: the commercial type of the server -* `__meta_scaleway_baremetal_zone`: the zone of the server (ex: `fr-par-1`, complete list [here](https://developers.scaleway.com/en/products/instance/api/#introduction)) - -This role uses the public IPv4 address by default. This can be -changed with relabeling, as demonstrated in [the Prometheus scaleway-sd -configuration file](/documentation/examples/prometheus-scaleway.yml). - -See below for the configuration options for Scaleway discovery: - -```yaml -# Access key to use. https://console.scaleway.com/project/credentials -access_key: - -# Secret key to use when listing targets. https://console.scaleway.com/project/credentials -# It is mutually exclusive with `secret_key_file`. -[ secret_key: ] - -# Sets the secret key with the credentials read from the configured file. -# It is mutually exclusive with `secret_key`. -[ secret_key_file: ] - -# Project ID of the targets. -project_id: - -# Role of the targets to retrieve. Must be `instance` or `baremetal`. -role: - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# API URL to use when doing the server listing requests. -[ api_url: | default = "https://api.scaleway.com" ] - -# Zone is the availability zone of your targets (e.g. fr-par-1). -[ zone: | default = fr-par-1 ] - -# NameFilter specify a name filter (works as a LIKE) to apply on the server listing request. -[ name_filter: ] - -# TagsFilter specify a tag filter (a server needs to have all defined tags to be listed) to apply on the server listing request. -tags_filter: -[ - ] - -# Refresh interval to re-read the targets list. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Uyuni SD configurations allow retrieving scrape targets from managed systems -via [Uyuni](https://www.uyuni-project.org/) API. - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_uyuni_endpoint_name`: the name of the application endpoint -* `__meta_uyuni_exporter`: the exporter exposing metrics for the target -* `__meta_uyuni_groups`: the system groups of the target -* `__meta_uyuni_metrics_path`: metrics path for the target -* `__meta_uyuni_minion_hostname`: hostname of the Uyuni client -* `__meta_uyuni_primary_fqdn`: primary FQDN of the Uyuni client -* `__meta_uyuni_proxy_module`: the module name if _Exporter Exporter_ proxy is - configured for the target -* `__meta_uyuni_scheme`: the protocol scheme used for requests -* `__meta_uyuni_system_id`: the system ID of the client - -See below for the configuration options for Uyuni discovery: - -```yaml -# The URL to connect to the Uyuni server. -server: - -# Credentials are used to authenticate the requests to Uyuni API. -username: -password: - -# The entitlement string to filter eligible systems. -[ entitlement: | default = monitoring_entitled ] - -# The string by which Uyuni group names are joined into the groups label. -[ separator: | default = , ] - -# Refresh interval to re-read the managed targets list. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -See [the Prometheus uyuni-sd configuration file](/documentation/examples/prometheus-uyuni.yml) -for a practical example on how to set up Uyuni Prometheus configuration. - -### `` - -Vultr SD configurations allow retrieving scrape targets from [Vultr](https://www.vultr.com/). - -This service discovery uses the main IPv4 address by default, which that be -changed with relabeling, as demonstrated in [the Prometheus vultr-sd -configuration file](/documentation/examples/prometheus-vultr.yml). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_vultr_instance_id` : A unique ID for the vultr Instance. -* `__meta_vultr_instance_label` : The user-supplied label for this instance. -* `__meta_vultr_instance_os` : The Operating System name. -* `__meta_vultr_instance_os_id` : The Operating System id used by this instance. -* `__meta_vultr_instance_region` : The Region id where the Instance is located. -* `__meta_vultr_instance_plan` : A unique ID for the Plan. -* `__meta_vultr_instance_main_ip` : The main IPv4 address. -* `__meta_vultr_instance_internal_ip` : The private IP address. -* `__meta_vultr_instance_main_ipv6` : The main IPv6 address. -* `__meta_vultr_instance_features` : List of features that are available to the instance. -* `__meta_vultr_instance_tags` : List of tags associated with the instance. -* `__meta_vultr_instance_hostname` : The hostname for this instance. -* `__meta_vultr_instance_server_status` : The server health status. -* `__meta_vultr_instance_vcpu_count` : Number of vCPUs. -* `__meta_vultr_instance_ram_mb` : The amount of RAM in MB. -* `__meta_vultr_instance_disk_gb` : The size of the disk in GB. -* `__meta_vultr_instance_allowed_bandwidth_gb` : Monthly bandwidth quota in GB. - -```yaml -# The port to scrape metrics from. -[ port: | default = 80 ] - -# The time after which the instances are refreshed. -[ refresh_interval: | default = 60s ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -### `` - -Outscale SD configurations allow retrieving scrape targets from [Outscale Cloud](https://outscale.com/) VMs via the Outscale API (OAPI). - -The following meta labels are available on targets during [relabeling](#relabel_config): - -* `__meta_outscale_vm_instance_id`: the ID of the VM -* `__meta_outscale_vm_region`: the region of the VM -* `__meta_outscale_vm_subregion`: the subregion of the VM -* `__meta_outscale_vm_state`: the state of the VM -* `__meta_outscale_vm_private_ip`: the private IP address of the VM -* `__meta_outscale_vm_public_ip`: the public IP address of the VM -* `__meta_outscale_vm_tag_`: each tag value; the tag key is sanitized and appended (e.g. tag key `Name` → `__meta_outscale_vm_tag_Name`) - -Targets use the first address found: private IP, then public IP. This can be changed with relabeling, as demonstrated in [the Prometheus outscale-sd configuration file](/documentation/examples/prometheus-outscale.yml). - -See below for the configuration options for Outscale discovery: - -```yaml -# Region to use. -[ region: | default = "eu-west-2" ] - -# Access key (20 alphanumeric characters). See https://docs.outscale.com/en/userguide/Creating-an-Access-Key.html -access_key: - -# Secret key (40 characters). Use one of `secret_key` or `secret_key_file`. -[ secret_key: ] - -# Secret key file. -[ secret_key_file: ] - -# API endpoint URL. Defaults to https://api..outscale.com/api/v1 if empty. -[ endpoint: ] - -# The port to scrape metrics from. -[ port: | default = 80 ] - -# Refresh interval to re-read the targets list. -[ refresh_interval: | default = 60s ] - -# HTTP client settings. -[ ] -``` - -### `` - -A `static_config` allows specifying a list of targets and a common label set -for them. It is the canonical way to specify static targets in a scrape -configuration. - -```yaml -# The targets specified by the static config. -targets: - [ - '' ] - -# Labels assigned to all metrics scraped from the targets. -labels: - [ : ... ] -``` - -The special labels mentioned in the [relabeling](#relabel_config) section can also be -used here to override the respective settings in the scrape configuration. This is -especially useful when combined with any of the service discovery mechanisms that do not -support these settings directly. - -### `` - -Relabeling is a powerful tool to dynamically rewrite the label set of a target before -it gets scraped. Multiple relabeling steps can be configured per scrape configuration. -They are applied to the label set of each target in order of their appearance -in the configuration file. - -Initially, aside from the configured per-target labels, a target's `job` -label is set to the `job_name` value of the respective scrape configuration. - -You can also use special labels like `__address__`, `__scheme__`, `__metrics_path__`, -`__scrape_interval__`, `__scrape_timeout__`, `__convert_classic_histograms_to_nhcb__`, -`__always_scrape_classic_histograms__`, `__scrape_native_histograms__` -to customize the defined targets. These will -override the respective settings in the scrape configuration. - -The `__address__` label is set to the `:` address of the target. -After relabeling, the `instance` label is set to the value of `__address__` by default if -it was not set during relabeling. - -The `__scheme__` and `__metrics_path__` labels -are set to the scheme and metrics path of the target respectively, as specified in `scrape_config`. - -The `__param_` -label is set to the value of the first passed URL parameter called ``, as defined in `scrape_config`. - -The `__scrape_interval__` and `__scrape_timeout__` labels are set to the target's -interval and timeout, as specified in `scrape_config`. - -The `__convert_classic_histograms_to_nhcb__` label is set to the target's -`convert_classic_histograms_to_nhcb` value, as specified in `scrape_config` -(defaulting to the configured global). Setting it during relabeling overrides, -per target, whether classic histograms are converted to native histograms with -custom buckets. Its value must parse as a boolean; a target with an invalid -value is dropped. - -The `__always_scrape_classic_histograms__` label is set to the target's -`always_scrape_classic_histograms` value, as specified in `scrape_config` -(defaulting to the configured global). Setting it during relabeling overrides, -per target, whether a classic histogram is also ingested when it is exposed as -a native histogram. Its value must parse as a boolean; a target with an invalid -value is dropped. - -The `__scrape_native_histograms__` label is set to the target's -`scrape_native_histograms` value, as specified in `scrape_config` (defaulting to -the configured global). Setting it during relabeling overrides, per target, -whether native histograms are scraped. Its value must parse as a boolean; a -target with an invalid value is dropped. - -Additional labels prefixed with `__meta_` may be available during the -relabeling phase. They are set by the service discovery mechanism that provided -the target and vary between mechanisms. - -Labels starting with `__` will be removed from the label set after target -relabeling is completed. - -If a relabeling step needs to store a label value only temporarily (as the -input to a subsequent relabeling step), use the `__tmp` label name prefix. This -prefix is guaranteed to never be used by Prometheus itself. - -```yaml -# The source_labels tells the rule what labels to fetch from the series. Any -# labels which do not exist get a blank value (""). Their content is concatenated -# using the configured separator and matched against the configured regular expression -# for the replace, keep, and drop actions. -[ source_labels: '[' [, ...] ']' ] - -# Separator placed between concatenated source label values. -[ separator: | default = ; ] - -# Label to which the resulting value is written in a replace action. -# It is mandatory for replace actions. Regex capture groups are available. -[ target_label: ] - -# Regular expression against which the extracted value is matched. -[ regex: | default = (.*) ] - -# Modulus to take of the hash of the source label values. -[ modulus: ] - -# Replacement value against which a regex replace is performed if the -# regular expression matches. Regex capture groups are available. -[ replacement: | default = $1 ] - -# Action to perform based on regex matching. -[ action: | default = replace ] -``` - -`` is any valid -[RE2 regular expression](https://github.com/google/re2/wiki/Syntax). It is -required for the `replace`, `keep`, `drop`, `labelmap`,`labeldrop` and `labelkeep` actions. The regex is -anchored on both ends. To un-anchor the regex, use `.*.*`. - -`` determines the relabeling action to take: - -* `replace`: Match `regex` against the concatenated `source_labels`. Then, set - `target_label` to `replacement`, with match group references - (`${1}`, `${2}`, ...) in `replacement` substituted by their value. If `regex` - does not match, no replacement takes place. -* `lowercase`: Maps the concatenated `source_labels` to their lower case. -* `uppercase`: Maps the concatenated `source_labels` to their upper case. -* `keep`: Drop targets for which `regex` does not match the concatenated `source_labels`. -* `drop`: Drop targets for which `regex` matches the concatenated `source_labels`. -* `keepequal`: Drop targets for which the concatenated `source_labels` do not match `target_label`. -* `dropequal`: Drop targets for which the concatenated `source_labels` do match `target_label`. -* `hashmod`: Set `target_label` to the `modulus` of a hash of the concatenated `source_labels`. -* `labelmap`: Match `regex` against all source label names, not just those specified in `source_labels`. Then - copy the values of the matching labels to label names given by `replacement` with match - group references (`${1}`, `${2}`, ...) in `replacement` substituted by their value. -* `labeldrop`: Match `regex` against all label names. Any label that matches will be - removed from the set of labels. -* `labelkeep`: Match `regex` against all label names. Any label that does not match will be - removed from the set of labels. - -Care must be taken with `labeldrop` and `labelkeep` to ensure that metrics are -still uniquely labeled once the labels are removed. - -### `` - -Metric relabeling is applied to samples as the last step before ingestion. It -has the same configuration format and actions as target relabeling. Metric -relabeling does not apply to automatically generated timeseries such as `up`. - -One use for this is to exclude time series that are too expensive to ingest. - -### `` - -Alert relabeling is applied to alerts before they are sent to the Alertmanager. -It has the same configuration format and actions as target relabeling. Alert -relabeling is applied after external labels. - -One use for this is ensuring a HA pair of Prometheus servers with different -external labels send identical alerts. - -### `` - -An `alertmanager_config` section specifies Alertmanager instances the Prometheus -server sends alerts to. It also provides parameters to configure how to -communicate with these Alertmanagers. - -Alertmanagers may be statically configured via the `static_configs` parameter or -dynamically discovered using one of the supported service-discovery mechanisms. - -Additionally, `relabel_configs` allow selecting Alertmanagers from discovered -entities and provide advanced modifications to the used API path, which is exposed -through the `__alerts_path__` label. - -```yaml -# Per-target Alertmanager timeout when pushing alerts. -[ timeout: | default = 10s ] - -# The api version of Alertmanager. -[ api_version: | default = v2 ] - -# Prefix for the HTTP path alerts are pushed to. -[ path_prefix: | default = / ] - -# Configures the protocol scheme used for requests. -[ scheme: | default = http ] - -# Optionally configures AWS's Signature Verification 4 signing process to sign requests. -# Cannot be set at the same time as basic_auth, authorization, oauth2, azuread or google_iam. -# To use the default credentials from the AWS SDK, use `sigv4: {}`. -sigv4: - # The AWS region. If blank, the region from the default credentials chain - # is used. - [ region: ] - - # The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID` - # and `AWS_SECRET_ACCESS_KEY` are used. - [ access_key: ] - [ secret_key: ] - - # Named AWS profile used to authenticate. - [ profile: ] - - # AWS Role ARN, an alternative to using AWS API keys. - [ role_arn: ] - - # AWS External ID used when assuming a role. - # Can only be used with role_arn. - [ external_id: ] - - # Defines the FIPS mode for the AWS STS endpoint. - # Requires Prometheus >= 2.54.0 - # Note: FIPS STS selection should be configured via use_fips_sts_endpoint rather than environment variables. (The problem report that motivated this: AWS_USE_FIPS_ENDPOINT no longer works.) - [ use_fips_sts_endpoint: | default = false ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] - -# List of AWS service discovery configurations. -aws_sd_configs: - [ - ... ] - -# List of Azure service discovery configurations. -azure_sd_configs: - [ - ... ] - -# List of Consul service discovery configurations. -consul_sd_configs: - [ - ... ] - -# List of DNS service discovery configurations. -dns_sd_configs: - [ - ... ] - -# List of EC2 service discovery configurations. -ec2_sd_configs: - [ - ... ] - -# List of Eureka service discovery configurations. -eureka_sd_configs: - [ - ... ] - -# List of file service discovery configurations. -file_sd_configs: - [ - ... ] - -# List of DigitalOcean service discovery configurations. -digitalocean_sd_configs: - [ - ... ] - -# List of Docker service discovery configurations. -docker_sd_configs: - [ - ... ] - -# List of Docker Swarm service discovery configurations. -dockerswarm_sd_configs: - [ - ... ] - -# List of GCE service discovery configurations. -gce_sd_configs: - [ - ... ] - -# List of Hetzner service discovery configurations. -hetzner_sd_configs: - [ - ... ] - -# List of HTTP service discovery configurations. -http_sd_configs: - [ - ... ] - - # List of IONOS service discovery configurations. -ionos_sd_configs: - [ - ... ] - -# List of Kubernetes service discovery configurations. -kubernetes_sd_configs: - [ - ... ] - -# List of Lightsail service discovery configurations. -lightsail_sd_configs: - [ - ... ] - -# List of Linode service discovery configurations. -linode_sd_configs: - [ - ... ] - -# List of Marathon service discovery configurations. -marathon_sd_configs: - [ - ... ] - -# List of AirBnB's Nerve service discovery configurations. -nerve_sd_configs: - [ - ... ] - -# List of Nomad service discovery configurations. -nomad_sd_configs: - [ - ... ] - -# List of OpenStack service discovery configurations. -openstack_sd_configs: - [ - ... ] - -# List of Outscale service discovery configurations. -outscale_sd_configs: - [ - ... ] - -# List of OVHcloud service discovery configurations. -ovhcloud_sd_configs: - [ - ... ] - -# List of PuppetDB service discovery configurations. -puppetdb_sd_configs: - [ - ... ] - -# List of Scaleway service discovery configurations. -scaleway_sd_configs: - [ - ... ] - -# List of Zookeeper Serverset service discovery configurations. -serverset_sd_configs: - [ - ... ] - -# List of STACKIT service discovery configurations. -stackit_sd_configs: - [ - ... ] - -# List of Triton service discovery configurations. -triton_sd_configs: - [ - ... ] - -# List of Uyuni service discovery configurations. -uyuni_sd_configs: - [ - ... ] - -# List of Vultr service discovery configurations. -vultr_sd_configs: - [ - ... ] - -# List of labeled statically configured Alertmanagers. -static_configs: - [ - ... ] - -# List of Alertmanager relabel configurations. -relabel_configs: - [ - ... ] - -# List of alert relabel configurations. -alert_relabel_configs: - [ - ... ] -``` - -### `` - -`write_relabel_configs` is relabeling applied to samples before sending them -to the remote endpoint. Write relabeling is applied after external labels. This -could be used to limit which samples are sent. - -There is a [small demo](/documentation/examples/remote_storage) of how to use -this functionality. - -```yaml -# The URL of the endpoint to send samples to. -url: - -# protobuf message to use when writing to the remote write endpoint. -# -# * The `prometheus.WriteRequest` represents the message introduced in Remote Write 1.0, which -# will be deprecated eventually. -# * The `io.prometheus.write.v2.Request` was introduced in Remote Write 2.0 and replaces the former, -# by improving efficiency and sending metadata, start timestamp and native histograms by default. -# -# Before changing this value, consult with your remote storage provider (or test) what message it supports. -# Read more on https://prometheus.io/docs/specs/remote_write_spec_2_0/#io-prometheus-write-v2-request -[ protobuf_message: | default = prometheus.WriteRequest ] - -# Timeout for requests to the remote write endpoint. -[ remote_timeout: | default = 30s ] - -# Custom HTTP headers to be sent along with each remote write request. -# Be aware that headers that are set by Prometheus itself can't be overwritten. -headers: - [ : ... ] - -# List of remote write relabel configurations. -write_relabel_configs: - [ - ... ] - -# Name of the remote write config, which if specified must be unique among remote write configs. -# The name will be used in metrics and logging in place of a generated value to help users distinguish between -# remote write configs. -[ name: ] - -# Enables sending of exemplars over remote write. Note that exemplar storage itself must be enabled for exemplars to be scraped in the first place. -[ send_exemplars: | default = false ] - -# Enables sending of native histograms, also known as sparse histograms, over remote write. -# For the `io.prometheus.write.v2.Request` message, this option is noop (always true). -[ send_native_histograms: | default = false ] - -# When enabled, remote-write will resolve the URL host name via DNS, choose one of the IP addresses at random, and connect to it. -# When disabled, remote-write relies on Go's standard behavior, which is to try to connect to each address in turn. -# The connection timeout applies to the whole operation, i.e. in the latter case it is spread over all attempt. -# This is an experimental feature, and its behavior might still change, or even get removed. -[ round_robin_dns: | default = false ] - -# Optionally configures AWS's Signature Verification 4 signing process to -# sign requests. Cannot be set at the same time as basic_auth, authorization, oauth2, or azuread. -# To use the default credentials from the AWS SDK, use `sigv4: {}`. -sigv4: - # The AWS region. If blank, the region from the default credentials chain - # is used. - [ region: ] - - # The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID` - # and `AWS_SECRET_ACCESS_KEY` are used. - [ access_key: ] - [ secret_key: ] - - # Named AWS profile used to authenticate. - [ profile: ] - - # AWS Role ARN, an alternative to using AWS API keys. - [ role_arn: ] - - # AWS External ID used when assuming a role. - # Can only be used with role_arn. - [ external_id: ] - - # Defines the FIPS mode for the AWS STS endpoint. - # Requires Prometheus >= 2.54.0 - # Note: FIPS STS selection should be configured via use_fips_sts_endpoint rather than environment variables. (The problem report that motivated this: AWS_USE_FIPS_ENDPOINT no longer works.) - [ use_fips_sts_endpoint: | default = false ] - -# Optional AzureAD configuration. -# Cannot be used at the same time as basic_auth, authorization, oauth2, sigv4 or google_iam. -azuread: - # The Azure Cloud. Options are 'AzurePublic', 'AzureChina', or 'AzureGovernment'. - [ cloud: | default = AzurePublic ] - - # Azure Managed Identity. Leave 'client_id' blank to use the default managed identity. - [ managed_identity: - [ client_id: ] ] - - # Azure Workload Identity. - [ workload_identity: - client_id: - tenant_id: - [ token_file_path: | default = "/var/run/secrets/azure/tokens/azure-identity-token" ] ] - - # Azure OAuth. - [ oauth: - [ client_id: ] - [ client_secret: ] - [ tenant_id: ] ] - - # Azure Certificate-based authentication. - [ certificate: - client_id: - tenant_id: - certificate_path: - # Optional path to private key file if separate from certificate - [ certificate_key_path: ] - # Optional password for password-protected certificate files (PFX/PKCS12) - [ certificate_password: ] - # Whether to send the certificate chain in the x5c header - [ send_certificate_chain: | default = false ] ] - - # Azure SDK auth. - # See https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication - [ sdk: - [ tenant_id: ] ] - - # Optional custom OAuth 2.0 scope to request when acquiring tokens. - # If not specified, defaults to the appropriate monitoring scope for the cloud: - # - AzurePublic: https://monitor.azure.com//.default - # - AzureGovernment: https://monitor.azure.us//.default - # - AzureChina: https://monitor.azure.cn//.default - # Use this to authenticate against custom Azure applications or non-standard endpoints. - [ scope: ] - -# WARNING: Remote write is NOT SUPPORTED by Google Cloud. This configuration is reserved for future use. -# Optional Google Cloud Monitoring configuration. -# Cannot be used at the same time as basic_auth, authorization, oauth2, sigv4 or azuread. -# To use the default credentials from the Google Cloud SDK, use `google_iam: {}`. -google_iam: - # Service account key with monitoring write permissions. - credentials_file: - -# Configures the queue used to write to remote storage. -queue_config: - # Number of samples to buffer per shard before we block reading of more - # samples from the WAL. It is recommended to have enough capacity in each - # shard to buffer several requests to keep throughput up while processing - # occasional slow remote requests. - [ capacity: | default = 10000 ] - # Maximum number of shards, i.e. amount of concurrency. - [ max_shards: | default = 50 ] - # Minimum number of shards, i.e. amount of concurrency. - [ min_shards: | default = 1 ] - # Maximum number of samples per send. - [ max_samples_per_send: | default = 2000] - # Maximum time a sample will wait for a send. The sample might wait less - # if the buffer is full. Further time might pass due to potential retries. - [ batch_send_deadline: | default = 5s ] - # Initial retry delay. Gets doubled for every retry. - [ min_backoff: | default = 30ms ] - # Maximum retry delay. - [ max_backoff: | default = 5s ] - # Retry upon receiving a 429 status code from the remote-write storage. - # This is experimental and might change in the future. - [ retry_on_http_429: | default = false ] - # If set, any sample that is older than sample_age_limit - # will not be sent to the remote storage. The default value is 0s, - # which means that all samples are sent. - [ sample_age_limit: | default = 0s ] - -# Configures the sending of series metadata to remote storage -# if the `prometheus.WriteRequest` message was chosen. When -# `io.prometheus.write.v2.Request` is used, metadata is always sent. -# -# Metadata configuration is subject to change at any point -# or be removed in future releases. -metadata_config: - # Whether metric metadata is sent to remote storage or not. - [ send: | default = true ] - # How frequently metric metadata is sent to remote storage. - [ send_interval: | default = 1m ] - # Maximum number of samples per send. - [ max_samples_per_send: | default = 500] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -# enable_http2 defaults to false for remote-write. -[ ] -``` - -There is a list of -[integrations](https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage) -with this feature. - -### `` - -```yaml -# The URL of the endpoint to query from. -url: - -# Name of the remote read config, which if specified must be unique among remote read configs. -# The name will be used in metrics and logging in place of a generated value to help users distinguish between -# remote read configs. -[ name: ] - -# An optional list of equality matchers which have to be -# present in a selector to query the remote read endpoint. -required_matchers: - [ : ... ] - -# Timeout for requests to the remote read endpoint. -[ remote_timeout: | default = 1m ] - -# Custom HTTP headers to be sent along with each remote read request. -# Be aware that headers that are set by Prometheus itself can't be overwritten. -headers: - [ : ... ] - -# Whether reads should be made for queries for time ranges that -# the local storage should have complete data for. -[ read_recent: | default = false ] - -# Whether to use the external labels as selectors for the remote read endpoint. -[ filter_external_labels: | default = true ] - -# HTTP client settings, including authentication methods (such as basic auth and -# authorization), proxy configurations, TLS options, custom HTTP headers, etc. -[ ] -``` - -There is a list of -[integrations](https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage) -with this feature. - -### `` - -`tsdb` lets you configure the runtime-reloadable configuration settings of the TSDB. - -```yaml -# Configures how old an out-of-order/out-of-bounds sample can be w.r.t. the TSDB max time. -# An out-of-order/out-of-bounds sample is ingested into the TSDB as long as the timestamp -# of the sample is >= TSDB.MaxTime-out_of_order_time_window. -# -# When out_of_order_time_window is >0, the errors out-of-order and out-of-bounds are -# combined into a single error called 'too-old'; a sample is either (a) ingestible -# into the TSDB, i.e. it is an in-order sample or an out-of-order/out-of-bounds sample -# that is within the out-of-order window, or (b) too-old, i.e. not in-order -# and before the out-of-order window. -# -# When out_of_order_time_window is greater than 0, it also affects experimental agent. It allows -# the agent's WAL to accept out-of-order samples that fall within the specified time window relative -# to the timestamp of the last appended sample for the same series. -[ out_of_order_time_window: | default = 0s ] - -# Configures the trigger point for compacting the stale series from the memory into persistent blocks -# and remove those stale series from the memory. -# -# The threshold is a number between 0.0 and 1.0. It represents the ratio of stale series in the memory -# to the total series in the memory. The stale series compaction is triggered when this ratio crosses -# the configured threshold. It may not trigger the stale series compaction if the usual head compaction -# is about to happen soon. -# -# If set to 0, stale series compaction is disabled. -# -# This is an experimental feature, this behaviour could change or be removed in the future. -[ stale_series_compaction_threshold: | default = 0 ] - -# Configures the float chunk encoding to use for new chunks. -# Valid values are 'xor' and 'xor2'. When absent, the encoding follows the -# --enable-feature=xor2-encoding flag: 'xor2' if the flag is set, 'xor' otherwise. -# Setting 'xor' forces standard XOR encoding even when --enable-feature=xor2-encoding is set. -# Setting 'xor2' is only valid when --enable-feature=xor2-encoding is set; -# Prometheus will refuse to reload if 'xor2' is set without the feature flag. -# Setting 'xor' is incompatible with --enable-feature=st-storage (XOR chunks do not store -# start timestamps); Prometheus will refuse to reload in that case too. -# Omitting 'floats' (or the entire 'chunk_encoding' field) is equivalent; the encoding -# follows the --enable-feature=xor2-encoding flag. -# This field is runtime-reloadable. -# When --enable-feature=st-storage is disabled, XOR and XOR2 are compatible -# encodings and in-progress chunks are not cut on an encoding change; the new -# encoding takes effect when the current chunk is next cut for any reason (size, time range, or sample count). -# When --enable-feature=st-storage is enabled, XOR and XOR2 are not compatible -# (XOR chunks do not store start timestamps), so an in-progress chunk is cut -# on the next append after the encoding changes. -[ chunk_encoding: - [ floats: ] ] - -# Configures data retention settings for TSDB. -# -# Note: When retention is changed at runtime, the retention -# settings are updated immediately, but block deletion based on the new retention policy -# occurs during the next block reload cycle. This happens automatically within 1 minute -# or when a compaction completes, whichever comes first. -[ retention: ] : - # How long to retain samples in storage. If neither this option nor the size option - # is set, the retention time defaults to 15d. Setting this to 0 disables time-based retention. - # This option takes precedence over the deprecated command-line flag --storage.tsdb.retention.time. - [ time: ] - - # Maximum number of bytes that can be stored for blocks. A unit is required, - # supported units: B, KB, MB, GB, TB, PB, EB. Ex: "512MB". Based on powers-of-2, so 1KB is 1024B. - # If set to 0 or not set, size-based retention is disabled. - # This option takes precedence over the deprecated command-line flag --storage.tsdb.retention.size. - [ size: | default = 0 ] - - # Maximum percent of total disk space allowed for storage of blocks. Alternative to `size` and - # behaves the same as if size was calculated by hand as a percentage of the total storage capacity. - # Prometheus will fail to start if this config is enabled, but it fails to query the total storage capacity. - # The total disk space allowed will automatically adapt to volume resize. - # If set to 0 or not set, percentage-based retention is disabled. - # - # This is an experimental feature, this behaviour could change or be removed in the future. - [ percentage: | default = 0 ] -``` - -### `` - -Note that exemplar storage is still considered experimental and must be enabled via `--enable-feature=exemplar-storage`. - -```yaml -# Configures the maximum size of the circular buffer used to store exemplars for all series. Resizable during runtime. -[ max_exemplars: | default = 100000 ] -``` - -### `` - -`tracing_config` configures exporting traces from Prometheus to a tracing backend via the OTLP protocol. Tracing is currently an **experimental** feature and could change in the future. - -```yaml -# Client used to export the traces. Options are 'http' or 'grpc'. -[ client_type: | default = grpc ] - -# Endpoint to send the traces to. Should be provided in format :. -[ endpoint: ] - -# Sets the probability a given trace will be sampled. Must be a float from 0 through 1. -[ sampling_fraction: | default = 0 ] - -# If disabled, the client will use a secure connection. -[ insecure: | default = false ] - -# Key-value pairs to be used as headers associated with gRPC or HTTP requests. -headers: - [ : ... ] - -# Compression key for supported compression types. Supported compression: gzip. -[ compression: ] - -# Maximum time the exporter will wait for each batch export. -[ timeout: | default = 10s ] - -# TLS configuration. -tls_config: - [ ] -``` - -If query logging and tracing are both enabled, a traceID and spanID will be injected -into the query log file for use in log/trace correlation. diff --git a/docs/configuration/https.md b/docs/configuration/https.md deleted file mode 100644 index 9a089ca922..0000000000 --- a/docs/configuration/https.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: HTTPS and authentication -sort_rank: 7 ---- - -Prometheus supports basic authentication and TLS. -This is **experimental** and might change in the future. - -To specify which web configuration file to load, use the `--web.config.file` flag. - -The file is written in [YAML format](https://en.wikipedia.org/wiki/YAML), -defined by the scheme described below. -Brackets indicate that a parameter is optional. For non-list parameters the -value is set to the specified default. - -The file is read upon every http request, such as any change in the -configuration and the certificates is picked up immediately. - -Generic placeholders are defined as follows: - -* ``: a boolean that can take the values `true` or `false` -* ``: a valid path in the current working directory -* ``: a regular string that is a secret, such as a password -* ``: a regular string - -A valid example file can be found [here](/documentation/examples/web-config.yml). - -```yaml -tls_server_config: - # Certificate and key files for server to use to authenticate to client. - cert_file: - key_file: - - # Server policy for client authentication. Maps to ClientAuth Policies. - # For more detail on clientAuth options: - # https://golang.org/pkg/crypto/tls/#ClientAuthType - # - # NOTE: If you want to enable client authentication, you need to use - # RequireAndVerifyClientCert. Other values are insecure. - [ client_auth_type: | default = "NoClientCert" ] - - # CA certificate for client certificate authentication to the server. - [ client_ca_file: ] - - # Verify that the client certificate has a Subject Alternate Name (SAN) - # which is an exact match to an entry in this list, else terminate the - # connection. SAN match can be one or multiple of the following: DNS, - # IP, e-mail, or URI address from https://pkg.go.dev/crypto/x509#Certificate. - [ client_allowed_sans: - [ - ] ] - - # Minimum TLS version that is acceptable. - [ min_version: | default = "TLS12" ] - - # Maximum TLS version that is acceptable. - [ max_version: | default = "TLS13" ] - - # List of supported cipher suites for TLS versions up to TLS 1.2. If empty, - # Go default cipher suites are used. Available cipher suites are documented - # in the go documentation: - # https://golang.org/pkg/crypto/tls/#pkg-constants - # - # Note that only the cipher returned by the following function are supported: - # https://pkg.go.dev/crypto/tls#CipherSuites - [ cipher_suites: - [ - ] ] - - # prefer_server_cipher_suites controls whether the server selects the - # client's most preferred ciphersuite, or the server's most preferred - # ciphersuite. If true then the server's preference, as expressed in - # the order of elements in cipher_suites, is used. - [ prefer_server_cipher_suites: | default = true ] - - # Elliptic curves that will be used in an ECDHE handshake, in preference - # order. Available curves are documented in the go documentation: - # https://golang.org/pkg/crypto/tls/#CurveID - [ curve_preferences: - [ - ] ] - -http_server_config: - # Enable HTTP/2 support. Note that HTTP/2 is only supported with TLS. - # This can not be changed on the fly. - [ http2: | default = true ] - # List of headers that can be added to HTTP responses. - [ headers: - # Set the Content-Security-Policy header to HTTP responses. - # Unset if blank. - [ Content-Security-Policy: ] - # Set the X-Frame-Options header to HTTP responses. - # Unset if blank. Accepted values are deny and sameorigin. - # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options - [ X-Frame-Options: ] - # Set the X-Content-Type-Options header to HTTP responses. - # Unset if blank. Accepted value is nosniff. - # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options - [ X-Content-Type-Options: ] - # Set the X-XSS-Protection header to all responses. - # Unset if blank. - # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection - [ X-XSS-Protection: ] - # Set the Strict-Transport-Security header to HTTP responses. - # Unset if blank. - # Please make sure that you use this with care as this header might force - # browsers to load Prometheus and the other applications hosted on the same - # domain and subdomains over HTTPS. - # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security - [ Strict-Transport-Security: ] ] - -# Usernames and hashed passwords that have full access to the web -# server via basic authentication. If empty, no basic authentication is -# required. Passwords are hashed with bcrypt. -basic_auth_users: - [ : ... ] -``` - diff --git a/docs/configuration/index.md b/docs/configuration/index.md deleted file mode 100644 index 5cfaf2a556..0000000000 --- a/docs/configuration/index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Configuration -sort_rank: 3 ---- diff --git a/docs/configuration/promtool.md b/docs/configuration/promtool.md deleted file mode 100644 index d127ad080c..0000000000 --- a/docs/configuration/promtool.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -title: HTTP configuration for promtool -sort_rank: 6 ---- - -Promtool is a versatile CLI tool for Prometheus that supports validation, debugging, querying, unit testing, tsdb management, pushing data, and experimental PromQL editing. - -Prometheus supports basic authentication and TLS. Since promtool needs to connect to Prometheus, we need to provide the authentication details. To specify those authentication details, use the `--http.config.file` for all requests that need to communicate with Prometheus. -For instance, if you would like to check whether your local Prometheus server is healthy, you would use: -```bash -promtool check healthy --url=http://localhost:9090 --http.config.file=http-config-file.yml -``` - -The file is written in [YAML format](https://en.wikipedia.org/wiki/YAML), defined by the schema described below. -Brackets indicate that a parameter is optional. For non-list parameters the value is set to the specified default. - -The file is read upon every http request, such as any change in the -configuration and the certificates is picked up immediately. - -Generic placeholders are defined as follows: - -* ``: a boolean that can take the values `true` or `false` -* ``: a valid path to a file -* ``: a regular string that is a secret, such as a password -* ``: a regular string - -A valid example file can be found [here](/documentation/examples/promtool-http-config-file.yml). - -```yaml -# Note that `basic_auth` and `authorization` options are mutually exclusive. - -# Sets the `Authorization` header with the configured username and password. -# `username_ref` and `password_ref`refer to the name of the secret within the secret manager. -# `password`, `password_file` and `password_ref` are mutually exclusive. -basic_auth: - [ username: ] - [ username_file: ] - [ username_ref: ] - [ password: ] - [ password_file: ] - [ password_ref: ] - -# Optional the `Authorization` header configuration. -authorization: - # Sets the authentication type. - [ type: | default: Bearer ] - # Sets the credentials. It is mutually exclusive with - # `credentials_file`. - [ credentials: ] - # Sets the credentials with the credentials read from the configured file. - # It is mutually exclusive with `credentials`. - [ credentials_file: ] - [ credentials_ref: ] - -# Optional OAuth 2.0 configuration. -# Cannot be used at the same time as basic_auth or authorization. -oauth2: - [ ] - -tls_config: - [ ] - -[ follow_redirects: | default: true ] - -# Whether to enable HTTP2. -[ enable_http2: | default: true ] - -# Optional proxy URL. -[ proxy_url: ] -# Comma-separated string that can contain IPs, CIDR notation, domain names -# that should be excluded from proxying. IP and domain names can -# contain port numbers. -[ no_proxy: ] -[ proxy_from_environment: ] -[ proxy_connect_header: - [ : [ , ... ] ] ] - -# `http_headers` specifies a set of headers that will be injected into each request. -http_headers: - [ :
] -``` - -## \ -OAuth 2.0 authentication using the client credentials grant type. -```yaml -# `client_id` and `client_secret` are used to authenticate your -# application with the authorization server in order to get -# an access token. -# `client_secret`, `client_secret_file` and `client_secret_ref` are mutually exclusive. -client_id: -[ client_secret: ] -[ client_secret_file: ] -[ client_secret_ref: ] - -# `scopes` specify the reason for the resource access. -scopes: - [ - ...] - -# The URL to fetch the token from. -token_url: - -# Optional parameters to append to the token URL. -[ endpoint_params: - : ... ] - -# Configures the token request's TLS settings. -tls_config: - [ ] - -# Optional proxy URL. -[ proxy_url: ] -# Comma-separated string that can contain IPs, CIDR notation, domain names -# that should be excluded from proxying. IP and domain names can -# contain port numbers. -[ no_proxy: ] -[ proxy_from_environment: ] -[ proxy_connect_header: - [ : [ , ... ] ] ] -``` - -## -```yaml -# For the following configurations, use either `ca`, `cert` and `key` or `ca_file`, `cert_file` and `key_file` or use `ca_ref`, `cert_ref` or `key_ref`. -# Text of the CA certificate to use for the server. -[ ca: ] -# CA certificate to validate the server certificate with. -[ ca_file: ] -# `ca_ref` is the name of the secret within the secret manager to use as the CA cert. -[ ca_ref: ] - -# Text of the client cert file for the server. -[ cert: ] -# Certificate file for client certificate authentication. -[ cert_file: ] -# `cert_ref` is the name of the secret within the secret manager to use as the client certificate. -[ cert_ref: ] - -# Text of the client key file for the server. -[ key: ] -# Key file for client certificate authentication. -[ key_file: ] -# `key_ref` is the name of the secret within the secret manager to use as the client key. -[ key_ref: ] - -# ServerName extension to indicate the name of the server. -# http://tools.ietf.org/html/rfc4366#section-3.1 -[ server_name: ] - -# Disable validation of the server certificate. -[ insecure_skip_verify: ] - -# Minimum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS -# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3). -# If unset, promtool will use Go default minimum version, which is TLS 1.2. -# See MinVersion in https://pkg.go.dev/crypto/tls#Config. -[ min_version: ] -# Maximum acceptable TLS version. Accepted values: TLS10 (TLS 1.0), TLS11 (TLS -# 1.1), TLS12 (TLS 1.2), TLS13 (TLS 1.3). -# If unset, promtool will use Go default maximum version, which is TLS 1.3. -# See MaxVersion in https://pkg.go.dev/crypto/tls#Config. -[ max_version: ] -``` - -## \ -`header` represents the configuration for a single HTTP header. -```yaml -[ values: - [ - ... ] ] - -[ secrets: - [ - ... ] ] - -[ files: - [ - ... ] ] -``` diff --git a/docs/configuration/recording_rules.md b/docs/configuration/recording_rules.md deleted file mode 100644 index 6d668a4da3..0000000000 --- a/docs/configuration/recording_rules.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: Defining recording rules -nav_title: Recording rules -sort_rank: 2 ---- - -## Configuring rules - -Prometheus supports two types of rules which may be configured and then -evaluated at regular intervals: recording rules and [alerting -rules](alerting_rules.md). To include rules in Prometheus, create a file -containing the necessary rule statements and have Prometheus load the file via -the `rule_files` field in the [Prometheus configuration](configuration.md). -Rule files use YAML. - -The rule files can be reloaded at runtime by sending `SIGHUP` to the Prometheus -process. The changes are only applied if all rule files are well-formatted. - -## Syntax-checking rules - -To quickly check whether a rule file is syntactically correct without starting -a Prometheus server, you can use Prometheus's `promtool` command-line utility -tool: - -```bash -promtool check rules /path/to/example.rules.yml -``` - -The `promtool` binary is part of the `prometheus` archive offered on the -project's [download page](https://prometheus.io/download/). - -When the file is syntactically valid, the checker prints a textual -representation of the parsed rules to standard output and then exits with -a `0` return status. - -If there are any syntax errors or invalid input arguments, it prints an error -message to standard error and exits with a `1` return status. - -## Recording rules - -Recording rules allow you to precompute frequently needed or computationally -expensive expressions and save their result as a new set of time series. -Querying the precomputed result will then often be much faster than executing -the original expression every time it is needed. This is especially useful for -dashboards, which need to query the same expression repeatedly every time they -refresh. - -Recording and alerting rules exist in a rule group. Rules within a group are -run sequentially at a regular interval, with the same evaluation time. -The names of recording rules must be -[valid metric names](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). -The names of alerting rules must be -[valid label values](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). - -The syntax of a rule file is: - -```yaml -groups: - [ - ] -``` - -A simple example rules file would be: - -```yaml -groups: - - name: example - rules: - - record: code:prometheus_http_requests_total:sum - expr: sum by (code) (prometheus_http_requests_total) -``` - -### `` - -```yaml -# The name of the group. Must be unique within a file. -name: - -# How often rules in the group are evaluated. -[ interval: | default = global.evaluation_interval ] - -# Limit the number of alerts an alerting rule and series a recording -# rule can produce. 0 is no limit. -[ limit: | default = 0 ] - -# Offset the rule evaluation timestamp of this particular group by the specified duration into the past. -[ query_offset: | default = global.rule_query_offset ] - -# Labels to add or overwrite before storing the result for its rules. -# Labels defined in will override the key if it has a collision. -labels: - [ : ] - -rules: - [ - ... ] -``` - -### `` - -The syntax for recording rules is: - -```yaml -# The name of the time series to output to. Must be a valid metric name. -record: - -# The PromQL expression to evaluate. Every evaluation cycle this is -# evaluated at the current time, and the result recorded as a new set of -# time series with the metric name as given by 'record'. -expr: - -# Labels to add or overwrite before storing the result. -labels: - [ : ] -``` - -The syntax for alerting rules is: - -```yaml -# The name of the alert. Must be a valid label value. -alert: - -# The PromQL expression to evaluate. Every evaluation cycle this is -# evaluated at the current time, and all resultant time series become -# pending/firing alerts. -expr: - -# Alerts are considered firing once they have been returned for this long. -# Alerts which have not yet fired for long enough are considered pending. -[ for: | default = 0s ] - -# How long an alert will continue firing after the condition that triggered it -# has cleared. -[ keep_firing_for: | default = 0s ] - -# Labels to add or overwrite for each alert. -labels: - [ : ] - -# Annotations to add to each alert. -annotations: - [ : ] -``` - -See also the -[best practices for naming metrics created by recording rules](https://prometheus.io/docs/practices/rules/#recording-rules). - -## Limiting alerts and series - -A limit for alerts produced by alerting rules and series produced recording rules -can be configured per-group. When the limit is exceeded, _all_ series produced -by the rule are discarded, and if it's an alerting rule, _all_ alerts for -the rule, active, pending, or inactive, are cleared as well. The event will be -recorded as an error in the evaluation, and as such no stale markers are -written. - -## Rule query offset -This is useful to ensure the underlying metrics have been received and stored in Prometheus. Metric availability delays are more likely to occur when Prometheus is running as a remote write target due to the nature of distributed systems, but can also occur when there's anomalies with scraping and/or short evaluation intervals. - -## Failed rule evaluations due to slow evaluation - -If a rule group hasn't finished evaluating before its next evaluation is supposed to start (as defined by the `evaluation_interval`), the next evaluation will be skipped. Subsequent evaluations of the rule group will continue to be skipped until the initial evaluation either completes or times out. When this happens, there will be a gap in the metric produced by the recording rule. The `rule_group_iterations_missed_total` metric will be incremented for each missed iteration of the rule group. diff --git a/docs/configuration/template_examples.md b/docs/configuration/template_examples.md deleted file mode 100644 index bd076b256e..0000000000 --- a/docs/configuration/template_examples.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: Template examples -sort_rank: 4 ---- - -Prometheus supports templating in the annotations and labels of alerts, -as well as in served console pages. Templates have the ability to run -queries against the local database, iterate over data, use conditionals, -format data, etc. The Prometheus templating language is based on the [Go -templating](https://golang.org/pkg/text/template/) system. - -## Simple alert field templates - -```yaml -alert: InstanceDown -expr: up == 0 -for: 5m -labels: - severity: page -annotations: - summary: "Instance {{$labels.instance}} down" - description: "{{$labels.instance}} of job {{$labels.job}} has been down for more than 5 minutes." -``` - -Alert field templates will be executed during every rule iteration for each -alert that fires, so keep any queries and templates lightweight. If you have a -need for more complicated templates for alerts, it is recommended to link to a -console instead. - -## Simple iteration - -This displays a list of instances, and whether they are up: - -``` -{{ range query "up" }} - {{ .Labels.instance }} {{ .Value }} -{{ end }} -``` - -The special `.` variable contains the value of the current sample for each loop iteration. - -## Display one value - -``` -{{ with query "some_metric{instance='someinstance'}" }} - {{ . | first | value | humanize }} -{{ end }} -``` - -Go and Go's templating language are both strongly typed, so one must check that -samples were returned to avoid an execution error. For example this could -happen if a scrape or rule evaluation has not run yet, or a host was down. - -The included `prom_query_drilldown` template handles this, allows for -formatting of results, and linking to the [expression browser](https://prometheus.io/docs/visualization/browser/). - -## Using console URL parameters - -``` -{{ with printf "node_memory_MemTotal{job='node',instance='%s'}" .Params.instance | query }} - {{ . | first | value | humanize1024 }}B -{{ end }} -``` - -If accessed as `console.html?instance=hostname`, `.Params.instance` will evaluate to `hostname`. - -## Advanced iteration - -```html - -{{ range printf "node_network_receive_bytes{job='node',instance='%s',device!='lo'}" .Params.instance | query | sortByLabel "device"}} - - - - - - - - - {{ end }} -
{{ .Labels.device }}
Received{{ with printf "rate(node_network_receive_bytes{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device | query }}{{ . | first | value | humanize }}B/s{{end}}
Transmitted{{ with printf "rate(node_network_transmit_bytes{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device | query }}{{ . | first | value | humanize }}B/s{{end}}
-``` - -Here we iterate over all network devices and display the network traffic for each. - -As the `range` action does not specify a variable, `.Params.instance` is not -available inside the loop as `.` is now the loop variable. - -## Defining reusable templates - -Prometheus supports defining templates that can be reused. This is particularly -powerful when combined with -[console library](template_reference.md#console-templates) support, allowing -sharing of templates across consoles. - -``` -{{/* Define the template */}} -{{define "myTemplate"}} - do something -{{end}} - -{{/* Use the template */}} -{{template "myTemplate"}} -``` - -Templates are limited to one argument. The `args` function can be used to wrap multiple arguments. - -``` -{{define "myMultiArgTemplate"}} - First argument: {{.arg0}} - Second argument: {{.arg1}} -{{end}} -{{template "myMultiArgTemplate" (args 1 2)}} -``` diff --git a/docs/configuration/template_reference.md b/docs/configuration/template_reference.md deleted file mode 100644 index 30725a0b04..0000000000 --- a/docs/configuration/template_reference.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Template reference -sort_rank: 5 ---- - -Prometheus supports templating in the annotations and labels of alerts, -as well as in served console pages. Templates have the ability to run -queries against the local database, iterate over data, use conditionals, -format data, etc. The Prometheus templating language is based on the [Go -templating](https://golang.org/pkg/text/template/) system. - -## Data Structures - -The primary data structure for dealing with time series data is the sample, defined as: - -```go -type sample struct { - Labels map[string]string - Value interface{} -} -``` - -The metric name of the sample is encoded in a special `__name__` label in the `Labels` map. - -`[]sample` means a list of samples. - -`interface{}` in Go is similar to a void pointer in C. - -## Functions - -In addition to the [default -functions](https://golang.org/pkg/text/template/#hdr-Functions) provided by Go -templating, Prometheus provides functions for easier processing of query -results in templates. - -If functions are used in a pipeline, the pipeline value is passed as the last argument. - -### Queries - -| Name | Arguments | Returns | Notes | -| ------------- | ------------- | -------- | -------- | -| query | query string | []sample | Queries the database, does not support returning range vectors. | -| first | []sample | sample | Equivalent to `index a 0` | -| label | label, sample | string | Equivalent to `index sample.Labels label` | -| value | sample | interface{} | Equivalent to `sample.Value` | -| sortByLabel | label, []samples | []sample | Sorts the samples by the given label. Is stable. | - -`first`, `label` and `value` are intended to make query results easily usable in pipelines. - -### Numbers - -| Name | Arguments | Returns | Notes | -|---------------------| -----------------| --------| --------- | -| humanize | number or string | string | Converts a number to a more readable format, using [metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix). -| humanize1024 | number or string | string | Like `humanize`, but uses 1024 as the base rather than 1000. | -| humanizeDuration | number or string | string | Converts a duration in seconds to a more readable format. | -| humanizePercentage | number or string | string | Converts a ratio value to a fraction of 100. | -| humanizeTimestamp | number or string | string | Converts a Unix timestamp in seconds to a more readable format. | -| toTime | number or string | *time.Time | Converts a Unix timestamp in seconds to a time.Time. | -| toDuration | number or string | *time.Duration | Converts a duration in seconds to a time.Duration. | -| now | none | float64 | Returns the Unix timestamp in seconds at the time of the template evaluation. | - -Humanizing functions are intended to produce reasonable output for consumption -by humans, and are not guaranteed to return the same results between Prometheus -versions. - -### Strings - -| Name | Arguments | Returns | Notes | -| ------------- | ------------- | ------- | ----------- | -| title | string | string | [cases.Title](https://pkg.go.dev/golang.org/x/text/cases#Title), capitalises first character of each word.| -| toUpper | string | string | [strings.ToUpper](https://golang.org/pkg/strings/#ToUpper), converts all characters to upper case.| -| toLower | string | string | [strings.ToLower](https://golang.org/pkg/strings/#ToLower), converts all characters to lower case.| -| stripPort | string | string | [net.SplitHostPort](https://pkg.go.dev/net#SplitHostPort), splits string into host and port, then returns only host.| -| match | pattern, text | boolean | [regexp.MatchString](https://golang.org/pkg/regexp/#MatchString) Tests for a unanchored regexp match. | -| reReplaceAll | pattern, replacement, text | string | [Regexp.ReplaceAllString](https://golang.org/pkg/regexp/#Regexp.ReplaceAllString) Regexp substitution, unanchored. | -| graphLink | expr | string | Returns path to graph view in the [expression browser](https://prometheus.io/docs/visualization/browser/) for the expression. | -| tableLink | expr | string | Returns path to tabular ("Table") view in the [expression browser](https://prometheus.io/docs/visualization/browser/) for the expression. | -| parseDuration | string | float | Parses a duration string such as "1h" into the number of seconds it represents. | -| stripDomain | string | string | Removes the domain part of a FQDN. Leaves port untouched. | -| urlQueryEscape | string | string | [url.QueryEscape](https://pkg.go.dev/net/url#QueryEscape) Escapes the string so it can be safely placed inside a URL query. | - -### Others - -| Name | Arguments | Returns | Notes | -| ------------- | ------------- | ------- | ----------- | -| args | []interface{} | map[string]interface{} | This converts a list of objects to a map with keys arg0, arg1 etc. This is intended to allow multiple arguments to be passed to templates. | -| tmpl | string, []interface{} | nothing | Like the built-in `template`, but allows non-literals as the template name. Note that the result is assumed to be safe, and will not be auto-escaped. Only available in consoles. | -| safeHtml | string | string | Marks string as HTML not requiring auto-escaping. | -| externalURL | _none_ | string | The external URL under which Prometheus is externally reachable. | -| pathPrefix | _none_ | string | The external URL [path](https://pkg.go.dev/net/url#URL) for use in console templates. | - -## Template type differences - -Each of the types of templates provide different information that can be used to -parameterize templates, and have a few other differences. - -### Alert field templates - -`.Value`, `.Labels`, `.ExternalLabels`, and `.ExternalURL` contain the alert value, the alert -labels, the globally configured external labels, and the external URL (configured with `--web.external-url`) respectively. They are -also exposed as the `$value`, `$labels`, `$externalLabels`, and `$externalURL` variables for -convenience. - -### Console templates - -Consoles are exposed on `/consoles/`, and sourced from the directory pointed to -by the `-web.console.templates` flag. - -Console templates are rendered with -[html/template](https://golang.org/pkg/html/template/), which provides -auto-escaping. To bypass the auto-escaping use the `safe*` functions., - -URL parameters are available as a map in `.Params`. To access multiple URL -parameters by the same name, `.RawParams` is a map of the list values for each -parameter. The URL path is available in `.Path`, excluding the `/consoles/` -prefix. The globally configured external labels are available as -`.ExternalLabels`. There are also convenience variables for all four: -`$rawParams`, `$params`, `$path`, and `$externalLabels`. - -Consoles also have access to all the templates defined with `{{define -"templateName"}}...{{end}}` found in `*.lib` files in the directory pointed to -by the `-web.console.libraries` flag. As this is a shared namespace, take care -to avoid clashes with other users. Template names beginning with `prom`, -`_prom`, and `__` are reserved for use by Prometheus, as are the functions -listed above. diff --git a/docs/configuration/unit_testing_rules.md b/docs/configuration/unit_testing_rules.md deleted file mode 100644 index af94c414f0..0000000000 --- a/docs/configuration/unit_testing_rules.md +++ /dev/null @@ -1,312 +0,0 @@ ---- -title: Unit testing for rules -sort_rank: 6 ---- - -You can use `promtool` to test your rules. - -```shell -# For a single test file. -./promtool test rules test.yml - -# If you have multiple test files, say test1.yml,test2.yml,test3.yml -./promtool test rules test1.yml test2.yml test3.yml -``` - -## Test file format - -```yaml -# This is a list of rule files to consider for testing. Globs are supported. -rule_files: - [ - ] - -[ evaluation_interval: | default = 1m ] - -# Setting fuzzy_compare true will very slightly weaken floating point comparisons. -# This will (effectively) ignore differences in the last bit of the mantissa. -[ fuzzy_compare: | default = false ] - -# The order in which group names are listed below will be the order of evaluation of -# rule groups (at a given evaluation time). The order is guaranteed only for the groups mentioned below. -# All the groups need not be mentioned below. -group_eval_order: - [ - ] - -# All the tests are listed here. -tests: - [ - ] -``` - -### `` - -``` yaml -# Series data -[ interval: | default = evaluation_interval ] -input_series: - [ - ] - -# Name of the test group -[ name: ] - -# Start timestamp for the test group. This sets the base time for all samples -# and evaluations in this test group. -# Accepts either a Unix timestamp (e.g., 1609459200) or an RFC3339 formatted -# timestamp (e.g., "2021-01-01T00:00:00Z"). -# Default: 0 (Unix epoch: 1970-01-01 00:00:00 UTC) -# -# When set: -# - All input_series samples are timestamped starting from start_timestamp -# - The eval_time in test cases is relative to start_timestamp -# - The time() function returns start_timestamp + eval_time -[ start_timestamp: | | default = 0 ] - -# Unit tests for the above data. - -# Unit tests for alerting rules. We consider the alerting rules from the input file. -alert_rule_test: - [ - ] - -# Unit tests for PromQL expressions. -promql_expr_test: - [ - ] - -# External labels accessible to the alert template. -external_labels: - [ : ... ] - -# External URL accessible to the alert template. -# Usually set using --web.external-url. - [ external_url: ] -``` - -### `` - -```yaml -# This follows the usual series notation '{