Skip to content

Commit

Permalink
Merge pull request #65 from xenit-eu/master
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
anghelutar authored Jan 14, 2021
2 parents 53a8575 + 7518eeb commit 1d9671b
Show file tree
Hide file tree
Showing 18 changed files with 1,115 additions and 1,987 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ Version template:
-->

# Alfred Telemetry Changelog
## [0.4.1] - UNRELEASED

## [0.4.0] - 2020-01-12

## [0.4.0] - UNRELEASED
### Added

* Jetty metrics for alfred-telemetry-solr [#61]

[#61]: https://github.com/xenit-eu/alfred-telemetry/pull/61

## [0.3.1] - 2020-12-11

Expand Down
2 changes: 1 addition & 1 deletion alfred-telemetry-platform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ext {
}

dependencies {
implementation enforcedPlatform("org.alfresco:acs-packaging:${alfrescoVersion}")
alfrescoProvided enforcedPlatform("org.alfresco:acs-packaging:${alfrescoVersion}")

alfrescoProvided('org.alfresco:alfresco-repository')

Expand Down
33 changes: 28 additions & 5 deletions alfred-telemetry-solr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ supports numerous monitoring systems.

This Solr extension offers:

* flexibility to setup and define custom metrics very easily.
* flexibility to setup and define custom metrics easily
* a wide range of out of the box instrumentation


Expand All @@ -15,7 +15,8 @@ At the moment Alfred Telemetry Solr extension auto-configures a CompositeRegistr
* a [`PrometheusMeterRegistry`](https://micrometer.io/docs/registry/prometheus)
* a [`GraphiteMeterRegistry`](https://micrometer.io/docs/registry/graphite)

The extension implements a MicrometerHandler which binds all available metrics to the global registry. For graphite the handler needs to be called once in the beginning, which is done via an init script added to the image.
The extension implements a MicrometerHandler which binds all available metrics to the global registry.
For graphite the handler needs to be called once in the beginning, which is done via an init script added to the image.

In order to visualize correctly the output, a DummyResponseWriter is also provided, which simply displays verbatim the output of Prometheus scraping.

Expand All @@ -28,8 +29,6 @@ See examples in integration tests.

At the moment only Prometheus and Graphite are supported as monitoring systems.

For Graphite the library offered by micrometer conflicts with the library from inside solr6 and therefore replaces that one.

Disabling and configuring the graphite registry can be done via environment variables:

| Variable | Default |
Expand Down Expand Up @@ -110,10 +109,20 @@ At the moment following metrics are included:

See metrics provided by TomcatMetrics [here](https://github.com/micrometer-metrics/micrometer/tree/master/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/tomcat).

## Jetty metrics

Jetty metrics binding provides several jetty-related metrics.
At the moment following metrics are included:

* JettyStatisticsMetrics

See metrics provided by JettyStatisticsMetrics [here](https://github.com/micrometer-metrics/micrometer/tree/master/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jetty/JettyStatisticsMetrics.java).

Note: JettyStatisticsMetrics has been deprecated in favor of TimedHandler, but that requires a newer version of jetty than the one shipped in solr artifacts.

## Custom metrics

Following custom metrics have been implemented.
Besides metrics offered by micrometer, following custom metrics have been implemented:

### Solr core stats metrics

Expand Down Expand Up @@ -236,6 +245,20 @@ and the ResponseWriter:

<lib dir="lib/" regex=".*\.jar" />
<queryResponseWriter name="dummy" class="eu.xenit.alfred.telemetry.solr.writer.DummyResponseWriter"/>

In case of solr6, add to jetty.xml loading of StatisticsHandler:

<Call name="insertHandler">
<Arg>
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler" />
</Arg>
</Call>

and in solr-jetty-context.xml make sure server classes are available to the webapp:

<Call name="prependServerClass">
<Arg>-org.eclipse.jetty.server.</Arg>
</Call>
Restart solr.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.xenit.alfred.telemetry.solr.monitoring.registry;

import eu.xenit.alfred.telemetry.solr.util.Util;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
Expand All @@ -13,14 +14,22 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RegistryRegistraar {
public class RegistryRegistrar {
private static RegistryRegistrar registrar = null;

private static final Logger logger = LoggerFactory.getLogger(RegistryRegistraar.class);
private static final Logger logger = LoggerFactory.getLogger(RegistryRegistrar.class);
CompositeMeterRegistry globalMeterRegistry = Metrics.globalRegistry;
PrometheusMeterRegistry prometheusMeterRegistry;
GraphiteMeterRegistry graphiteMeterRegistry;

public RegistryRegistraar() {

public static RegistryRegistrar getInstance() {
if(registrar == null)
registrar = new RegistryRegistrar();
return registrar;
}

private RegistryRegistrar() {
// always register the Prometheus registry
prometheusMeterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
prometheusMeterRegistry.config().commonTags(Tags.of("application", "solr"));
Expand Down Expand Up @@ -75,12 +84,12 @@ private String tryToRetrieveHostName() {
}
}

public CompositeMeterRegistry getGlobalMeterRegistry() {
return globalMeterRegistry;
public static MeterRegistry getGlobalMeterRegistry() {
return getInstance().globalMeterRegistry;
}

public PrometheusMeterRegistry getPrometheusMeterRegistry() {
return prometheusMeterRegistry;
public static PrometheusMeterRegistry getPrometheusMeterRegistry() {
return getInstance().prometheusMeterRegistry;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package eu.xenit.alfred.telemetry.solr.util;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;

public class Util {
// everything is enabled by default except graphite registry, tomcat and jetty metrics
private static final Set<String> DEFAULT_DISABLED_CONFIGS;
static {
Set<String> configs = new HashSet<>();
configs.add("ALFRED_TELEMETRY_EXPORT_GRAPHITE_ENABLED");
configs.add("METRICS_TOMCAT_ENABLED");
configs.add("METRICS_JETTY_ENABLED");
DEFAULT_DISABLED_CONFIGS = Collections.unmodifiableSet(configs);
}

private Util() {
// private ctor to hide implicit public one
Expand All @@ -31,10 +38,6 @@ public static boolean isEnabled(String env) {
return Boolean.parseBoolean(System.getenv(env));
}

// everything is enabled by default except graphite registry and tomcat metrics
return ("ALFRED_TELEMETRY_EXPORT_GRAPHITE_ENABLED".equals(env)?
false:
("METRICS_TOMCAT_ENABLED".equals(env) ? false:true));

return (DEFAULT_DISABLED_CONFIGS.contains(env)?false:true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import eu.xenit.alfred.telemetry.solr.monitoring.binder.ProcessMetrics;
import eu.xenit.alfred.telemetry.solr.monitoring.binder.SolrMetrics;
import eu.xenit.alfred.telemetry.solr.monitoring.binder.SystemMetrics;
import eu.xenit.alfred.telemetry.solr.monitoring.registry.RegistryRegistraar;
import eu.xenit.alfred.telemetry.solr.monitoring.registry.RegistryRegistrar;
import eu.xenit.alfred.telemetry.solr.util.PrometheusRegistryUtil;
import eu.xenit.alfred.telemetry.solr.util.Util;
import io.micrometer.core.instrument.MeterRegistry;
Expand All @@ -21,8 +21,7 @@

public class MicrometerHandler extends RequestHandlerBase {

static RegistryRegistraar registraar = new RegistryRegistraar();
static MeterRegistry registry = registraar.getGlobalMeterRegistry();
static MeterRegistry registry = RegistryRegistrar.getInstance().getGlobalMeterRegistry();
static SolrMetrics solrMetrics = null;
static MyTomcatMetrics tomcatMetrics = null;

Expand Down Expand Up @@ -52,7 +51,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
tomcatMetrics = new MyTomcatMetrics(mbeanServer);
tomcatMetrics.bindTo(registry);
}
writeTextToResponse(PrometheusRegistryUtil.extractPrometheusScrapeData(registraar.getPrometheusMeterRegistry()),
writeTextToResponse(PrometheusRegistryUtil.extractPrometheusScrapeData(RegistryRegistrar.getInstance().getPrometheusMeterRegistry()),
rsp);
}

Expand Down
Loading

0 comments on commit 1d9671b

Please sign in to comment.