Skip to content
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

Merged
merged 1 commit into from
May 2, 2017
Merged

New module http #4156

merged 1 commit into from
May 2, 2017

Conversation

christiangalsterer
Copy link
Contributor

  • Initial commit after creating a new PR

@christiangalsterer
Copy link
Contributor Author

@ruflin , here the new PR, as replacement for PR #4092

@elasticmachine
Copy link
Collaborator

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
@elasticmachine
Copy link
Collaborator

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.

Copy link
Member

@ruflin ruflin left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/outpust/outputs/

Copy link
Contributor Author

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:
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will fix

#-------------------------------- http Module --------------------------------
- module: http
metricsets: ["json"]
enabled: true
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

return nil, err
}

event := common.MapStr{
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)?

Copy link
Member

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?

@ruflin ruflin added Metricbeat Metricbeat review labels May 1, 2017
- Initial commit after creating a new PR
@christiangalsterer
Copy link
Contributor Author

Addressed most PR comments, excepts for the Docker container.

Copy link
Member

@ruflin ruflin left a 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"`
}{}
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree.

@ruflin
Copy link
Member

ruflin commented May 1, 2017

jenkins, test it

@ruflin ruflin merged commit b764e32 into elastic:master May 2, 2017
@ruflin
Copy link
Member

ruflin commented May 2, 2017

@christiangalsterer Merged. Thanks a lot for the contribution.

@ruflin ruflin mentioned this pull request May 2, 2017
@ruflin
Copy link
Member

ruflin commented May 2, 2017

@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.
Copy link
Contributor

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"?

Copy link
Contributor

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".

Copy link
Contributor

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.

ruflin added a commit to ruflin/beats that referenced this pull request May 2, 2017
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
monicasarbu pushed a commit that referenced this pull request May 4, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants