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

Adding dropwizard module #4022

Merged
merged 3 commits into from
Apr 20, 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 @@ -127,6 +127,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Adding support for custom http headers and TLS for metricbeat modules {pull}3945[3945]
- Add new MetricSet interfaces for developers (`Closer`, `ReportingFetcher`, and `PushMetricSet`). {pull}3908[3908]
- Add kubelet module {pull}3916[3916]
- Add dropwizard module {pull}4022[4022]

*Packetbeat*
- Add `fields` and `fields_under_root` to packetbeat protocols configurations. {pull}3518[3518]
Expand Down
5 changes: 5 additions & 0 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- ${PWD}/module/apache/_meta/env
- ${PWD}/module/ceph/_meta/env
- ${PWD}/module/couchbase/_meta/env
- ${PWD}/module/dropwizard/_meta/env
- ${PWD}/module/elasticsearch/_meta/env
- ${PWD}/module/haproxy/_meta/env
- ${PWD}/module/jolokia/_meta/env
Expand All @@ -42,6 +43,7 @@ services:
apache: { condition: service_healthy }
ceph: { condition: service_healthy }
couchbase: { condition: service_healthy }
dropwizard: { condition: service_healthy }
elasticsearch: { condition: service_healthy }
haproxy: { condition: service_healthy }
jolokia: { condition: service_healthy }
Expand All @@ -67,6 +69,9 @@ services:
couchbase:
build: ${PWD}/module/couchbase/_meta

dropwizard:
build: ${PWD}/module/dropwizard/_meta

elasticsearch:
extends:
file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml
Expand Down
14 changes: 14 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ grouped in the following categories:
* <<exported-fields-common>>
* <<exported-fields-couchbase>>
* <<exported-fields-docker>>
* <<exported-fields-dropwizard>>
* <<exported-fields-elasticsearch>>
* <<exported-fields-golang>>
* <<exported-fields-haproxy>>
Expand Down Expand Up @@ -1875,6 +1876,19 @@ type: long
Total number of outgoing packets.


[[exported-fields-dropwizard]]
== Dropwizard Fields

beta[]
Stats collected from Dropwizard.



[float]
== dropwizard Fields



[[exported-fields-elasticsearch]]
== elasticsearch Fields

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

[[metricbeat-module-dropwizard]]
== dropwizard Module

This is the http://dropwizard.io[Dropwizard] Module.



[float]
=== Example Configuration

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

[source,yaml]
----
metricbeat.modules:
#- module: dropwizard
#metricsets: ["collector"]
#enabled: true
#period: 10s
#hosts: ["localhost:8080"]
#metrics_path: /metrics/metrics
#namespace: example
----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-dropwizard-collector,collector>>

include::dropwizard/collector.asciidoc[]

19 changes: 19 additions & 0 deletions metricbeat/docs/modules/dropwizard/collector.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-dropwizard-collector]]
include::../../../module/dropwizard/collector/_meta/docs.asciidoc[]


==== Fields

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

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/dropwizard/collector/_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 @@ -6,6 +6,7 @@ This file is generated! See scripts/docs_collector.py
* <<metricbeat-module-ceph,ceph>>
* <<metricbeat-module-couchbase,Couchbase>>
* <<metricbeat-module-docker,Docker>>
* <<metricbeat-module-dropwizard,Dropwizard>>
* <<metricbeat-module-elasticsearch,elasticsearch>>
* <<metricbeat-module-golang,golang>>
* <<metricbeat-module-haproxy,HAProxy>>
Expand All @@ -32,6 +33,7 @@ include::modules/apache.asciidoc[]
include::modules/ceph.asciidoc[]
include::modules/couchbase.asciidoc[]
include::modules/docker.asciidoc[]
include::modules/dropwizard.asciidoc[]
include::modules/elasticsearch.asciidoc[]
include::modules/golang.asciidoc[]
include::modules/haproxy.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 @@ -28,6 +28,8 @@ import (
_ "github.com/elastic/beats/metricbeat/module/docker/info"
_ "github.com/elastic/beats/metricbeat/module/docker/memory"
_ "github.com/elastic/beats/metricbeat/module/docker/network"
_ "github.com/elastic/beats/metricbeat/module/dropwizard"
_ "github.com/elastic/beats/metricbeat/module/dropwizard/collector"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch/node"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch/node_stats"
Expand Down
9 changes: 9 additions & 0 deletions metricbeat/metricbeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ metricbeat.modules:
#certificate: "/etc/pki/client/cert.pem"
#key: "/etc/pki/client/cert.key"

#----------------------------- Dropwizard Module -----------------------------
#- module: dropwizard
#metricsets: ["collector"]
#enabled: true
#period: 10s
#hosts: ["localhost:8080"]
#metrics_path: /metrics/metrics
#namespace: example

#---------------------------- elasticsearch Module ---------------------------
#- module: elasticsearch
# metricsets: ["node", "node_stats", "stats"]
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/dropwizard/_meta/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/target
8 changes: 8 additions & 0 deletions metricbeat/module/dropwizard/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM maven:3.3-jdk-8
COPY test /test

HEALTHCHECK CMD curl -f http://localhost:8080/test/helloworld
EXPOSE 8080

WORKDIR /test
CMD mvn jetty:run
7 changes: 7 additions & 0 deletions metricbeat/module/dropwizard/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#- module: dropwizard
#metricsets: ["collector"]
#enabled: true
#period: 10s
#hosts: ["localhost:8080"]
#metrics_path: /metrics/metrics
#namespace: example
4 changes: 4 additions & 0 deletions metricbeat/module/dropwizard/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== dropwizard Module

This is the http://dropwizard.io[Dropwizard] Module.

2 changes: 2 additions & 0 deletions metricbeat/module/dropwizard/_meta/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROPWIZARD_HOST=dropwizard
DROPWIZARD_PORT=8080
12 changes: 12 additions & 0 deletions metricbeat/module/dropwizard/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- key: dropwizard
title: "Dropwizard"
description: >
beta[]

Stats collected from Dropwizard.
short_config: false
fields:
- name: dropwizard
type: group
description: >
fields:
1 change: 1 addition & 0 deletions metricbeat/module/dropwizard/_meta/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
40 changes: 40 additions & 0 deletions metricbeat/module/dropwizard/_meta/test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.test.dropwizard</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Test Webapp for dropwizard metrics</name>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.test.dropwizard;

import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.codahale.metrics.servlets.MetricsServlet;

/**
*
* MetricsServletContextListener is a listener class that needs to be added to all assertion
* web application's web.xml in order to expose the MetricsRegistry which maintains all the
* metrics that are being tracked.
*
*/

public class MetricsServletContextListener extends MetricsServlet.ContextListener {

public static MetricRegistry METRIC_REGISTRY = new MetricRegistry();

static {
Counter c = new Counter();
c.inc();
METRIC_REGISTRY.register("my_counter{this=that}", c);
METRIC_REGISTRY.register("my_meter{this=that}", new Meter());

METRIC_REGISTRY.register("my_timer", new Timer());
METRIC_REGISTRY.histogram("my_histogram");
METRIC_REGISTRY.register("my_gauge", new Gauge<Integer>() {

@Override
public Integer getValue() {
// TODO Auto-generated method stub
return null;
}

});

}

@Override
protected MetricRegistry getMetricRegistry() {
return METRIC_REGISTRY;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.test.dropwizard;

import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@SuppressWarnings("serial")
public class TestServlet extends HttpServlet {
@SuppressWarnings("unchecked")
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = null;
try {
out = new PrintWriter(resp.getWriter());
out.println("hello world");
out.flush();
} finally {
close(out);
}
}

private static void close(Closeable c) {
if (c == null) {
return;
}

try {
c.close();
} catch (IOException ignore) {
/* ignore */
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Test Dropwizard</display-name>

<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>io.test.dropwizard.TestServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/helloworld</url-pattern>
</servlet-mapping>

<listener>
<listener-class>io.test.dropwizard.MetricsServletContextListener</listener-class>
</listener>

<servlet>
<servlet-name>CodahaleMetrics</servlet-name>
<servlet-class>com.codahale.metrics.servlets.MetricsServlet</servlet-class>
<init-param>
<param-name>metrics-uri</param-name>
<param-value>/metrics</param-value>
</init-param>
<init-param>
<param-name>ping-uri</param-name>
<param-value>/ping</param-value>
</init-param>
<init-param>
<param-name>healthcheck-uri</param-name>
<param-value>/health</param-value>
</init-param>
<init-param>
<param-name>threads-uri</param-name>
<param-value>/threads</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>CodahaleMetrics</servlet-name>
<url-pattern>/metrics/*</url-pattern>
</servlet-mapping>


</web-app>
Loading