Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/prometheus/prometheus/discovery/marathon"
"github.com/prometheus/prometheus/discovery/moby"
"github.com/prometheus/prometheus/discovery/openstack"
"github.com/prometheus/prometheus/discovery/puppetdb"
"github.com/prometheus/prometheus/discovery/scaleway"
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/prometheus/prometheus/discovery/triton"
Expand Down Expand Up @@ -790,6 +791,34 @@ var expectedConf = &Config{
}},
},
},
{
JobName: "service-puppetdb",

HonorTimestamps: true,
ScrapeInterval: model.Duration(15 * time.Second),
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,

MetricsPath: DefaultScrapeConfig.MetricsPath,
Scheme: DefaultScrapeConfig.Scheme,
HTTPClientConfig: config.DefaultHTTPClientConfig,

ServiceDiscoveryConfigs: discovery.Configs{&puppetdb.SDConfig{
URL: "https://puppetserver/",
Query: "resources { type = \"Package\" and title = \"httpd\" }",
IncludeParameters: true,
Port: 80,
RefreshInterval: model.Duration(60 * time.Second),
HTTPClientConfig: config.HTTPClientConfig{
FollowRedirects: true,
TLSConfig: config.TLSConfig{
CAFile: "testdata/valid_ca_file",
CertFile: "testdata/valid_cert_file",
KeyFile: "testdata/valid_key_file",
},
},
},
},
},
{
JobName: "hetzner",
HonorTimestamps: true,
Expand Down Expand Up @@ -1262,6 +1291,22 @@ var expectedErrors = []struct {
filename: "empty_static_config.bad.yml",
errMsg: "empty or null section in static_configs",
},
{
filename: "puppetdb_no_query.bad.yml",
errMsg: "query missing",
},
{
filename: "puppetdb_no_url.bad.yml",
errMsg: "url missing",
},
{
filename: "puppetdb_bad_url.bad.yml",
errMsg: "host is missing in URL",
},
{
filename: "puppetdb_no_scheme.bad.yml",
errMsg: "url scheme must be http or https",
},
{
filename: "hetzner_role.bad.yml",
errMsg: "unknown role",
Expand Down
12 changes: 12 additions & 0 deletions config/testdata/conf.good.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,18 @@ scrape_configs:
cert_file: valid_cert_file
key_file: valid_key_file

- job_name: service-puppetdb
puppetdb_sd_configs:
- url: https://puppetserver/
query: 'resources { type = "Package" and title = "httpd" }'
include_parameters: true
port: 80
refresh_interval: 1m
tls_config:
ca_file: valid_ca_file
cert_file: valid_cert_file
key_file: valid_key_file

- job_name: hetzner
hetzner_sd_configs:
- role: hcloud
Expand Down
4 changes: 4 additions & 0 deletions config/testdata/puppetdb_bad_url.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scrape_configs:
- puppetdb_sd_configs:
- url: http://
query: 'resources { type = "Package" and title = "httpd" }'
3 changes: 3 additions & 0 deletions config/testdata/puppetdb_no_query.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scrape_configs:
- puppetdb_sd_configs:
- url: http://puppetserver/
4 changes: 4 additions & 0 deletions config/testdata/puppetdb_no_scheme.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scrape_configs:
- puppetdb_sd_configs:
- url: ftp://puppet
query: 'resources { type = "Package" and title = "httpd" }'
3 changes: 3 additions & 0 deletions config/testdata/puppetdb_no_url.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scrape_configs:
- puppetdb_sd_configs:
- query: 'resources { type = "Package" and title = "httpd" }'
1 change: 1 addition & 0 deletions discovery/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
_ "github.com/prometheus/prometheus/discovery/marathon" // register marathon
_ "github.com/prometheus/prometheus/discovery/moby" // register moby
_ "github.com/prometheus/prometheus/discovery/openstack" // register openstack
_ "github.com/prometheus/prometheus/discovery/puppetdb" // register puppetdb
_ "github.com/prometheus/prometheus/discovery/scaleway" // register scaleway
_ "github.com/prometheus/prometheus/discovery/triton" // register triton
_ "github.com/prometheus/prometheus/discovery/xds" // register xds
Expand Down
49 changes: 49 additions & 0 deletions discovery/puppetdb/fixtures/vhosts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"certname": "edinburgh.example.com",
"environment": "prod",
"exported": false,
"file": "/etc/puppetlabs/code/environments/prod/modules/upstream/apache/manifests/init.pp",
"line": 384,
"parameters": {
"access_log": true,
"access_log_file": "ssl_access_log",
"additional_includes": [ ],
"directoryindex": "",
"docroot": "/var/www/html",
"ensure": "absent",
"options": [
"Indexes",
"FollowSymLinks",
"MultiViews"
],
"php_flags": { },
"labels": {
"alias": "edinburgh"
},
"scriptaliases": [
{
"alias": "/cgi-bin",
"path": "/var/www/cgi-bin"
}
]
},
"resource": "49af83866dc5a1518968b68e58a25319107afe11",
"tags": [
"roles::hypervisor",
"apache",
"apache::vhost",
"class",
"default-ssl",
"profile_hypervisor",
"vhost",
"profile_apache",
"hypervisor",
"__node_regexp__edinburgh",
"roles",
"node"
],
"title": "default-ssl",
"type": "Apache::Vhost"
}
]
Loading