-
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
[#1262] Add Graylog input plugin #1261
Conversation
## HTTP Header parameters (all values must be strings) | ||
[inputs.graylog.headers] | ||
Authorization = "Basic YWRtaW46YWRtaW4" | ||
Content-Type = "application/json" |
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.
Why allow users to set these headers? Content-Type and Accept should ALWAYS be application/json. Authorization should be controlled by providing an "auth_key" argument to users, which the plugin would then internally create the Authorization header for the user.
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
All comments done, Please verify @sparrc |
"jvm.memory.pools.Metaspace.committed" | ||
] | ||
## User name and password | ||
[inputs.graylog.auth_key] |
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.
don't make inputs.graylog.auth_key a map, just use two arguments username
and password
directly in the plugin
@alimousazy Looks much better, thanks for the revisions, but there is one general change that I think still needs to happen. Since graylog appears to be returning a specific JSON format, like: {
"full_name": "org.graylog2.shared.journal.KafkaJournal.writeTime",
"metric": {
"time": {
"min": 99
},
"rate": {
"total": 10,
"mean": 2
},
"duration_unit": "microseconds",
"rate_unit": "events/second"
},
"name": "writeTime",
"type": "hdrtimer"
} It seems like you should marshal the response JSON onto an object that looks something like this: type ResponseMetrics struct {
total int
Metrics []map[string]metric `json:"metrics"`
}
type metric struct {
FullName string `json:"full_name"`
name string
type string
metric map[string]interface{}
} then you can make metric.FullName the telegraf metric name. Flatten metric.metric and make those the fields, and set metric.name and metric.type as tags. |
|
||
import ( | ||
"bytes" | ||
b64 "encoding/base64" |
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.
don't rename this import, use the built-in name
@sparrc Done |
type GrayLog struct { | ||
Name string | ||
Servers []string | ||
TagKeys []string |
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.
remove TagKeys from the code since they're not used anymore
|
} | ||
|
||
type GrayLog struct { | ||
Name string |
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.
Name
doesn't appear to be getting used anymore, can you also remove it?
Looking good @alimousazy, only other thing is |
add unit test for graylog
Done removing name @sparrc |
Required for all PRs: