-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add Icinga2 input plugin #2668 #4559
Conversation
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.
Thanks for this!
plugins/inputs/icinga2/icinga2.go
Outdated
# tls_cert = "/etc/telegraf/cert.pem" | ||
# tls_key = "/etc/telegraf/key.pem" | ||
## Use TLS but skip chain & host verification | ||
` |
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.
Missing insecure_skip_verify
example line.
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.
I added
plugins/inputs/icinga2/README.md
Outdated
# tls_cert = "/etc/telegraf/cert.pem" | ||
# tls_key = "/etc/telegraf/key.pem" | ||
## Use TLS but skip chain & host verification | ||
``` |
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.
Add # insecure_skip_verify = false
plugins/inputs/icinga2/icinga2.go
Outdated
# server = "https://localhost:5665" | ||
|
||
## Required Icinga2 object type ("services" or "hosts, default "services") | ||
# filter = "services" |
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.
Maybe make this a bool, something like defaulting to hosts=false
, meaning it will collect services only; unless there are other object types besides services
and hosts
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.
I actually prefer this style, if we have hosts=false then it isn't clear that it means services. Also if another object type has support added then a bool won't scale up to additional items. I also wonder if a user would ever want to collect both services and hosts? Maybe this should be an array: ["services", "hosts"]
? Finally, filter is a somewhat confusing because normally you filter things out, maybe it should be renamed object_type
?
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.
Oh ya, good call
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.
I agree, i renamed to object_type
plugins/inputs/icinga2/icinga2.go
Outdated
return err | ||
} | ||
|
||
req.SetBasicAuth(i.Username, i.Password) |
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.
Maybe only set this if Username/Password are not empty
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.
done
@glinton done |
when this will be merged |
plugins/inputs/icinga2/README.md
Outdated
|
||
### Measurements & Fields: | ||
|
||
- ll measurements have the following fields: |
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.
Small typo :)
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.
done, thanks :)
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.
I think there are just a few tweaks needed:
README.md
Outdated
@@ -165,6 +165,8 @@ configuration options. | |||
* [haproxy](./plugins/inputs/haproxy) | |||
* [hddtemp](./plugins/inputs/hddtemp) | |||
* [httpjson](./plugins/inputs/httpjson) (generic JSON-emitting http service plugin) | |||
* [icinga2](./plugins/inputs/icinga2) | |||
* [internal](./plugins/inputs/internal) |
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.
Can you fix the sorting of the plugin, internal is already listed so you can remove that line.
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.
done
plugins/inputs/icinga2/README.md
Outdated
- All measurements have the following tags: | ||
- check_command | ||
- display_name | ||
- source |
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.
Although not documented yet, as discussed in #4413 we are planning to standardize on source
as the hostname of the metric source and split out other components. Can you change the style of these tags to be:
source=example.org,port=5665,scheme=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.
done
plugins/inputs/icinga2/README.md
Outdated
|
||
- All measurements have the following fields: | ||
- name (string) | ||
- state (int) |
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.
We recently established a pattern for encoding enum like values in several plugins, the basic idea is to use a tag with a string description, and a field with the code:
icinga2,state=warning state_code=1
It looks like we would need a mapping function for each object type?
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.
done
"github.com/influxdata/telegraf/testutil" | ||
) | ||
|
||
func TestGatherStatus(t *testing.T) { |
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.
Add a unit test for object_type = "hosts" as well.
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.
done
plugins/inputs/icinga2/README.md
Outdated
@@ -0,0 +1,62 @@ | |||
# Example Input Plugin |
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.
Icinga2 Input Plugin
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.
done
plugins/inputs/icinga2/icinga2.go
Outdated
tags["check_command"] = check.Attrs.CheckCommand | ||
tags["source"] = i.Server | ||
|
||
acc.AddFields(fmt.Sprintf("icinga2_%s_status", i.ObjectType), fields, tags) |
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.
Optional: consider dropping the _status
suffix here, it feels superfluous.
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.
done
@danielnelson @glinton I have implemented all the required changes :) |
Resolves #2658
Required for all PRs: