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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Add dropwizard module {pull}4022[4022]
- Adding query APIs for metricsets and modules from metricbeat registry {pull}4102[4102]
- Fixing nil pointer on prometheus collector when http response is nil {pull}4119[4119]
- Add http module with json metricset. {pull}4092[4092]

*Packetbeat*
- Add `fields` and `fields_under_root` to packetbeat protocols configurations. {pull}3518[3518]
Expand Down
91 changes: 91 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ grouped in the following categories:
* <<exported-fields-elasticsearch>>
* <<exported-fields-golang>>
* <<exported-fields-haproxy>>
* <<exported-fields-http>>
* <<exported-fields-jolokia>>
* <<exported-fields-kafka>>
* <<exported-fields-kibana>>
Expand Down Expand Up @@ -3444,6 +3445,96 @@ type: integer
The average queue time in ms over the last 1024 requests.
[[exported-fields-http]]
== http Fields
http Module
[float]
== http Fields
[float]
== request Fields
HTTP request information
[float]
=== http.request.header
type: nested
The HTTP headers sent
[float]
=== http.request.method
type: keyword
The HTTP method used
[float]
=== http.request.body
type: keyword
The HTTP payload sent
[float]
== response Fields
HTTP response information
[float]
=== http.response.header
type: nested
The HTTP headers received
[float]
=== http.response.status_code
type: keyword
The HTTP status code
[float]
=== http.response.body
type: keyword
The HTTP payload received
[float]
== json Fields
json metricset
[float]
=== http.json.body
type: keyword
The HTTP payload received
[[exported-fields-jolokia]]
== Jolokia Fields
Expand Down
41 changes: 41 additions & 0 deletions metricbeat/docs/modules/http.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
////
This file is generated! See scripts/docs_collector.py
////

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

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


[float]
=== Example Configuration

The http module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: http
metricsets: ["json"]
enabled: false
period: 10s
hosts: ["httpbin.org"]
namespace: "http_json_namespace"
path: "/headers"
----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-http-json,json>>

include::http/json.asciidoc[]

19 changes: 19 additions & 0 deletions metricbeat/docs/modules/http/json.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-http-json]]
include::../../../module/http/json/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-http,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/http/json/_meta/data.json[]
----
2 changes: 2 additions & 0 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This file is generated! See scripts/docs_collector.py
* <<metricbeat-module-elasticsearch,elasticsearch>>
* <<metricbeat-module-golang,golang>>
* <<metricbeat-module-haproxy,HAProxy>>
* <<metricbeat-module-http,http>>
* <<metricbeat-module-jolokia,Jolokia>>
* <<metricbeat-module-kafka,kafka>>
* <<metricbeat-module-kibana,kibana>>
Expand Down Expand Up @@ -37,6 +38,7 @@ include::modules/dropwizard.asciidoc[]
include::modules/elasticsearch.asciidoc[]
include::modules/golang.asciidoc[]
include::modules/haproxy.asciidoc[]
include::modules/http.asciidoc[]
include::modules/jolokia.asciidoc[]
include::modules/kafka.asciidoc[]
include::modules/kibana.asciidoc[]
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/include/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
_ "github.com/elastic/beats/metricbeat/module/haproxy"
_ "github.com/elastic/beats/metricbeat/module/haproxy/info"
_ "github.com/elastic/beats/metricbeat/module/haproxy/stat"
_ "github.com/elastic/beats/metricbeat/module/http"
_ "github.com/elastic/beats/metricbeat/module/http/json"
_ "github.com/elastic/beats/metricbeat/module/jolokia"
_ "github.com/elastic/beats/metricbeat/module/jolokia/jmx"
_ "github.com/elastic/beats/metricbeat/module/kafka"
Expand Down
9 changes: 9 additions & 0 deletions metricbeat/metricbeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ metricbeat.modules:
period: 10s
hosts: ["tcp://127.0.0.1:14567"]

#-------------------------------- http Module --------------------------------
- module: http
metricsets: ["json"]
enabled: false
period: 10s
hosts: ["httpbin.org"]
namespace: "http_json_namespace"
path: "/headers"

#------------------------------- Jolokia Module ------------------------------
- module: jolokia
metricsets: ["jmx"]
Expand Down
11 changes: 11 additions & 0 deletions metricbeat/module/http/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.

FROM jolokia/java-jolokia:7
ENV TOMCAT_VERSION 7.0.55
ENV TC apache-tomcat-${TOMCAT_VERSION}

HEALTHCHECK CMD curl -f curl localhost:8778/jolokia/
EXPOSE 8778
RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz
RUN tar xzf ${TC}.tar.gz -C /opt

CMD env CATALINA_OPTS=$(jolokia_opts) /opt/${TC}/bin/catalina.sh run
7 changes: 7 additions & 0 deletions metricbeat/module/http/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- module: http
metricsets: ["json"]
enabled: false
period: 10s
hosts: ["httpbin.org"]
namespace: "http_json_namespace"
path: "/headers"
7 changes: 7 additions & 0 deletions metricbeat/module/http/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 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.
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 output 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.
2 changes: 2 additions & 0 deletions metricbeat/module/http/_meta/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JOLOKIA_HOST=jolokia
JOLOKIA_PORT=8778
43 changes: 43 additions & 0 deletions metricbeat/module/http/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
- key: http
title: "http"
description: >
http Module
fields:
- name: http
type: group
description: >
fields:
- name: request
type: group
description: >
HTTP request information
fields:
- name: header
type: nested
description: >
The HTTP headers sent
- name: method
type: keyword
description: >
The HTTP method used
- name: body
type: keyword
description: >
The HTTP payload sent
- name: response
type: group
description: >
HTTP response information
fields:
- name: header
type: nested
description: >
The HTTP headers received
- name: status_code
type: keyword
description: >
The HTTP status code
- name: body
type: keyword
description: >
The HTTP payload received
4 changes: 4 additions & 0 deletions metricbeat/module/http/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Package http is a Metricbeat module that contains MetricSets.
*/
package http
19 changes: 19 additions & 0 deletions metricbeat/module/http/json/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"@timestamp":"2016-05-23T08:05:34.853Z",
"beat":{
"hostname":"beathost",
"name":"beathost"
},
"metricset":{
"host":"localhost",
"module":"http",
"name":"json",
"rtt":44269
},
"http":{
"json":{
"example": "json"
}
},
"type":"metricsets"
}
Loading