-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
New module http #4156
New module http #4156
Conversation
christiangalsterer
commented
May 1, 2017
- Initial commit after creating a new PR
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
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.
@christiangalsterer I left a few comments on the PR. I'm also ok to merge it as is and take over the review comments in a second part if you prefer it.
Http module is a [Metricbeat](https://www.elastic.co/products/beats/metricbeat) used to call HTTP endpoints. | ||
Multiple endpoints can be configured which are polled in a regular interval and the result is shipped to the configured output channel. | ||
|
||
Httpbeat is inspired by the Logstash [http_poller](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html) input filter but doesn't require that the endpoint is reachable by Logstash as the Metricbeat module pushes the data to the configured outpust channels, e.g. Logstash or Elasticsearch. |
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.
s/outpust/outputs/
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.
ok, will fix
Httpbeat is inspired by the Logstash [http_poller](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html) input filter but doesn't require that the endpoint is reachable by Logstash as the Metricbeat module pushes the data to the configured outpust channels, e.g. Logstash or Elasticsearch. | ||
This is often necessary in security restricted network setups, where Logstash is not able to reach all servers. Instead the server to be monitored itself has Metricbeat installed and can send the data or a collector server has Metricbeat installed which is deployed in the secured network environment and can reach all servers to be monitored. | ||
|
||
Example use cases are: |
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 suggest to remove these examples as we cover these by its own modules (except spring-boot), but that should come as a module soon.
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.
ok, will fix
metricbeat/metricbeat.full.yml
Outdated
#-------------------------------- http Module -------------------------------- | ||
- module: http | ||
metricsets: ["json"] | ||
enabled: true |
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.
This should be set to enabled: false
by default.
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.
ok, will fix
@@ -0,0 +1,11 @@ | |||
# Tomcat is started to fetch Jolokia metrics from it |
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'm thinking if we could use a less "heavy" container for the http testing?
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.
Any suggestions? I reused the container Jolokia container as it was already there, so that no additional image needs to be build and an additional to be started.
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 was thinking of having our own very small web service in go that exposes and http endpoint and sends json to make it clear it is a "dynamic" metricset. Here we have something similar for dropwizard: https://github.com/elastic/beats/tree/master/metricbeat/module/dropwizard/_meta/test Except having a http service will hopefully only be a few lines of code and then in the container go run ...
can be directly used.
metricbeat/module/http/json/json.go
Outdated
return nil, err | ||
} | ||
|
||
event := common.MapStr{ |
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 would change this code as following. Note: code will not work directly probably because of some type conversion that is needed.
event := jsonBody
event["_namespace"] = m.namespace
if m.config.request.enabled {
event[mb.ModuleData]["request"] = common.MapStr{
"headers": m.getHeaders(response.Request.Header),
"method": response.Request.Method,
"body": m.body,
}
}
if m.config.response.enabled {
event[mb.ModuleData]["response"] = common.MapStr{
"headers": m.getHeaders(response.Request.Header),
"method": response.Request.Method,
"body": m.body,
}
}
The thinking behind this is as following:
- Httpbeat json is used either for self build http endpoints or for endpoints like spring which are not supported yet by Metricbeat. In these cases the json body contains all the relevant data. So in most cases the response header details is not too relevant if it is a 200.
- The json document should not be nested under
body
as we already have the namespace to put it under its separate namespace. - There are definitively use cases where request and response can become interesting, so we should have a config option to enable this. Be aware that these use cases will also overlap potentially with heartbeat and heartbeat could be the better tool for this use case.
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.
ok, will fix. W.r.t to heartbeat I definitely see also the overlap.
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.
one more question: Do you think we should add the custom config struct to the MetricSet (your example) or dedicated fields for each item (current approach)?
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.
For enable / disable it should be config options. Not sure what you mean by dedicated fields?
- Initial commit after creating a new PR
78af38c
to
2508f4c
Compare
Addressed most PR comments, excepts for the Docker container. |
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 a lot. LGTM. Will go through it in detail again later.
Body string `config:"body"` | ||
RequestEnabled bool `config:"request.enabled"` | ||
ResponseEnabled bool `config:"response.enabled"` | ||
}{} |
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 probably should define the "defaults" here in a follow up PR.
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.
Yes I agree.
jenkins, test it |
@christiangalsterer Merged. Thanks a lot for the contribution. |
@christiangalsterer I created here a minor follow up PR: #4170 |
[[metricbeat-module-http]] | ||
== http Module | ||
|
||
Http module is a [Metricbeat](https://www.elastic.co/products/beats/metricbeat) used to call arbitrary HTTP endpoints for which not a dedicated metricbeat is available. |
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 "module" after "a Metricbeat"?
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.
also there's an extra "not".
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.
Opps sorry, I intended to comment on #4170. Ignore these.
This is a follow up PR for elastic#4156 * Add environment with small golang web service * Remove not needed body fields * Add defaults to configs * Add system tests * Update config with all config options
This is a follow up PR for #4156 * Add environment with small golang web service * Remove not needed body fields * Add defaults to configs * Add system tests * Update config with all config options