Skip to content

Commit

Permalink
document PQL integration in prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Mar 28, 2024
1 parent 753c127 commit e517071
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions _docs/pql_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,39 @@ that had another class in their last catalog
puppet query 'resources { type = "Class" and title = "Profile::Core::Node_info" and certname in resources[certname] { type = "Class" and title = "Prometheus::Node_exporter" }}'
```

Why is that helpful? Prometheus has [native support to query PuppetDB](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#puppetdb_sd_config) and create a scrape config based on it (introduced in [github.com/prometheus/prometheus/commit/8920024323ad8fef353ec2fc495894f8748f0687](https://github.com/prometheus/prometheus/commit/8920024323ad8fef353ec2fc495894f8748f0687)):

```yaml
- job_name: node-exporter-dev
puppetdb_sd_configs:
- url: "http://puppetdb.local:8080"
query: |
resources {
type = "Class" and title = "Profile::Core::Node_info" and
certname in resources[certname] {
type = "Class" and title = "Prometheus::Node_exporter"
}
}
refresh_interval: 30s
follow_redirects: true
include_parameters: true
enable_http2: true
port: 9100
relabel_configs:
- source_labels: [__meta_puppetdb_certname]
target_label: instance
- source_labels: [__meta_puppetdb_environment]
target_label: environment
- source_labels: [__meta_puppetdb_parameter_site]
target_label: site
- source_labels: [__meta_puppetdb_parameter_role]
target_label: role
- source_labels: [__meta_puppetdb_parameter_cluster]
target_label: cluster
```
Thanks to [Julien "roidelapluie" Pivotto](mailto:[email protected]) for writing puppetdb_sd_config and thanks to [Joshua Hoblitt](https://github.com/jhoblitt) for figuring out the PQL Query and the config example.
## Endpoints and fields
The available endpoints is a function of which version of puppetdb you are going against. The current list is available at <https://puppet.com/docs/puppetdb/7/api/query/v4/entities.html>.
Expand Down

0 comments on commit e517071

Please sign in to comment.