-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Add PuppetDB service discovery #8883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We are using this in production. @mcanevet would you have some time to try this out as well? |
@roidelapluie do you have a pre-built docker image with this patch so that I don't have to build one? |
|
@roidelapluie Thanks for this PR. NB: I just had to remove the suffix |
ef3520f
to
19cee55
Compare
19cee55
to
49ade02
Compare
49ade02
to
e23a26b
Compare
This is ready for review, and tests are green. |
@roidelapluie Hi, I'm on vacation starting tomorrow until Sept 14 and won't be able to get to this before then. But happy to take a look after! |
Enjoy! |
Friendly ping :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a couple of nits :)
discovery/puppetdb/puppetdb.go
Outdated
return err | ||
} | ||
if c.URL == "" { | ||
return fmt.Errorf("url missing") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it consistent with file_sd
:
return fmt.Errorf("url missing") | |
return fmt.Errorf("URL is missing") |
discovery/puppetdb/puppetdb.go
Outdated
return err | ||
} | ||
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" { | ||
return fmt.Errorf("url scheme must be http or https") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same:
return fmt.Errorf("url scheme must be http or https") | |
return fmt.Errorf("URL scheme must be 'http' or 'https'") |
discovery/puppetdb/resources.go
Outdated
case string: | ||
labelValue = value | ||
case bool: | ||
labelValue = fmt.Sprintf("%t", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw., you can use strconv.FormatBool()
here:
labelValue = fmt.Sprintf("%t", value) | |
labelValue = strconv.FormatBool(value) |
discovery/puppetdb/resources.go
Outdated
case string: | ||
values[i] = value | ||
case bool: | ||
values[i] = fmt.Sprintf("%t", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
docs/configuration/configuration.md
Outdated
* `__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 or not the resource is exported (true, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `__meta_puppetdb_exported`: whether or not the resource is exported (true, false) | |
* `__meta_puppetdb_exported`: whether or not the resource is exported (`"true"` or `"false"`) |
docs/configuration/configuration.md
Outdated
* `__meta_puppetdb_exported`: whether or not the resource is exported (true, 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 to the resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"associated with"?
docs/configuration/configuration.md
Outdated
* `__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 to the resource | ||
* `__meta_puppetdb_parameter_<parametername>`: the parameters of the resouces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `__meta_puppetdb_parameter_<parametername>`: the parameters of the resouces | |
* `__meta_puppetdb_parameter_<parametername>`: the parameters of the resources |
docs/configuration/configuration.md
Outdated
# https://puppet.com/docs/puppetdb/latest/api/query/v4/pql.html | ||
query: <string> | ||
|
||
# Whether to include the parameters as labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it even clearer:
# Whether to include the parameters as labels. | |
# Whether to include the parameters as meta labels. |
I have addressed the comments |
@roidelapluie could it be that you need to rebase on the latest main to make the Netflify checks work? |
Other than that, 👍 |
...but IMO it'd also be ok to merge it with Netlify failing, since it doesn't touch anything UI-related. |
We have been Puppet user for 10 years and we are users of https://github.com/camptocamp/prometheus-puppetdb-sd However, that file_sd implementation contains business logic and assumptions around e.g. the modules which you are using. This pull request adds a simple PuppetDB service discovery, which will enable more use cases than the upstream sd. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
d101d5a
to
8920024
Compare
Rebased & squashed :) |
Hmm, now the Netlify deploy got cancelled with I think it's fine though. Merging :) |
We have been Puppet user for 10 years and we are users of
https://github.com/camptocamp/prometheus-puppetdb-sd
However, that file_sd implementation contains business logic and
assumptions around e.g. the modules which you are using.
This pull request adds a simple PuppetDB service discovery, which will
enable more use cases than the mentioned sd.
cc @raphink @mcanevet
Signed-off-by: Julien Pivotto roidelapluie@inuits.eu