-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
158ded2
commit c1132fa
Showing
16 changed files
with
136 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
# Tomcat is started to fetch Jolokia metrics from it | ||
FROM jolokia/java-jolokia:7 | ||
ENV TOMCAT_VERSION 7.0.55 | ||
ENV TC apache-tomcat-${TOMCAT_VERSION} | ||
FROM golang:1.8.1 | ||
|
||
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 | ||
COPY test/main.go main.go | ||
|
||
CMD env CATALINA_OPTS=$(jolokia_opts) /opt/${TC}/bin/catalina.sh run | ||
EXPOSE 8080 | ||
|
||
HEALTHCHECK CMD curl -f curl localhost:8080/ | ||
|
||
CMD go run main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
== 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. | ||
Http module is a [Metricbeat](https://www.elastic.co/products/beats/metricbeat) module used to call arbitrary HTTP endpoints for which a dedicated metricbeat module is not available. | ||
|
||
Multiple endpoints can be configured which are polled in a regular interval and the result is shipped to the configured output channel. It is recommended to install a metricbeat instance on each host from which data should be fetched. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
JOLOKIA_HOST=jolokia | ||
JOLOKIA_PORT=8778 | ||
HTTP_HOST=http | ||
HTTP_PORT=8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- key: http | ||
title: "http" | ||
title: "HTTP" | ||
description: > | ||
http Module | ||
fields: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", serve) | ||
err := http.ListenAndServe(":8080", nil) | ||
if err != nil { | ||
log.Fatal("ListenAndServe: ", err) | ||
} | ||
} | ||
|
||
func serve(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, `{"hello":"world"}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,3 @@ | |
description: > | ||
json metricset | ||
fields: | ||
- name: body | ||
type: keyword | ||
description: > | ||
The HTTP payload received |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import metricbeat | ||
import unittest | ||
from nose.plugins.attrib import attr | ||
|
||
HTTP_FIELDS = metricbeat.COMMON_FIELDS + ["http"] | ||
|
||
|
||
class Test(metricbeat.BaseTest): | ||
|
||
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test") | ||
def test_json(self): | ||
""" | ||
http json metricset test | ||
""" | ||
self.render_config_template(modules=[{ | ||
"name": "http", | ||
"metricsets": ["json"], | ||
"hosts": self.get_hosts(), | ||
"period": "5s", | ||
"namespace": "test", | ||
}]) | ||
proc = self.start_beat() | ||
self.wait_until(lambda: self.output_lines() > 0) | ||
proc.check_kill_and_wait() | ||
|
||
# Ensure no errors or warnings exist in the log. | ||
log = self.get_log() | ||
self.assertNotRegexpMatches(log.replace("WARN The http json metricset is in beta.", ""), "ERR|WARN") | ||
|
||
output = self.read_output_json() | ||
self.assertEqual(len(output), 1) | ||
evt = output[0] | ||
|
||
assert evt["http"]["test"]["hello"] == "world" | ||
|
||
# Delete dynamic namespace part for fields comparison | ||
del evt["http"]["test"] | ||
|
||
self.assertItemsEqual(self.de_dot(HTTP_FIELDS), evt.keys(), evt) | ||
|
||
self.assert_fields_are_documented(evt) | ||
|
||
def get_hosts(self): | ||
return ["http://" + os.getenv('HTTP_HOST', 'localhost') + ':' + | ||
os.getenv('HTTP_PORT', '8080')] |