Configuration
GigaSpaces provides a framework for collecting and reporting metrics from the distributed runtime environment into a metric repository of your choice, which can then be analysed and used to identify trends in the system behavior. Before you can start using the metrics framework you will need to first setup and configure your metric framework to work with GigaSpaces. GigaSpaces reports metrics using the Micrometer API, a framework that supports Open Telemetry and can be plugged in.
Overview
A Metric is a piece of code which provides a value of something at the current time (e.g. CPU percentage, free memory, active LRMI threads, etc.). GigaSpaces is bundled with an abundance of metrics which can be used to monitor its behaviour, and additional metrics can be defined by the user.
There are several frameworks that integrate out of the box with GigaSpaces:
- InfluxDB
- Prometheus
- File reporter (for development time testing)
Configuration
By default, Metrics configuration is loaded from $GS_HOME/config/metrics/metrics.properties. This location can be overridden using the com.gigaspaces.metrics.config system property, which also supports URL.
For example, setting multiple destinations for metrics to include all out-of-the-box integrations:
# Multiple destinations
metrics.registries=influxdb,prometheus,file
metrics.influxdb.uri=http://localhost:8086
metrics.influxdb.db=xap_metrics
metrics.influxdb.step=10
metrics.file.path=/var/log/xap/metrics.log
metrics.file.step=1
Plug in Other Frameworks
As an example, the following shows how to use Datadog. XAP
GigaSpaces eXtreme Application Platform.
Provides a powerful solution for data processing, launching, and running digital services's MicrometerRegistryBuilder uses ServiceLoader to discover GsMeterRegistryProvider implementations at startup. When metrics.registries=xyz is set, it:
- Scans all JARs in
$GS_HOME/lib/optional/metrics/forMETA-INF/services/com.gigaspaces.metrics.micrometer.GsMeterRegistryProvider - Finds
DatadogRegistryProvider, callsgetName()which matchesxyz - Calls
create(config)passing all properties frommetrics.propertiesas aPropertiesobject - The returned
DatadogMeterRegistryis registered as the active backend
In the example above, xyz can stand for datadog, dynatrace, or any other Open Telemetry framework.
Comparison with Built-in Backends
| Backend | How to Activate |
|---|---|
| InfluxDB | Built in — just set metrics.registries=influxdb and add required properties |
| Prometheus | Built in — just set metrics.registries=prometheus |
| Datadog / Graphite / New Relic / Wavefront / … | Plugin JAR — drop in lib/optional/metrics and set in metrics.properties |
Code Example: Datadog Implementation
Project structure:
datadog-metrics-provider/
├── pom.xml
├── README.md
└── src/main/
├── java/com/gigaspaces/example/metrics/datadog/
│ └── DatadogRegistryProvider.java
└── resources/META-INF/services/
└── com.gigaspaces.metrics.micrometer.GsMeterRegistryProvider/**
* Pluggable Datadog metrics backend for GigaSpaces XAP.
*
* Implements GsMeterRegistryProvider so that XAP discovers this class
* via ServiceLoader and activates it when metrics.registries=datadog is set
* in config/metrics/metrics.properties.
*
* Supported properties in metrics.properties:
* metrics.registries=datadog
* metrics.datadog.apiKey=<your-api-key> # required
* metrics.datadog.applicationKey=<your-app-key> # optional
* metrics.datadog.uri=https://api.datadoghq.com # optional, default shown
* metrics.datadog.step=10 # optional, seconds (default: 10)
*/
public class DatadogRegistryProvider implements GsMeterRegistryProvider {
@Override
public String getName() {
return "datadog";
}
@Override
public MeterRegistry create(Properties config) {
DatadogConfig datadogConfig = new DatadogConfig() {
@Override
public String apiKey() {
String key = config.getProperty("metrics.datadog.apiKey");
if (key == null || key.isBlank()) {
throw new IllegalStateException(
"metrics.datadog.apiKey is required but not set in metrics.properties");
}
return key;
}
@Override
public String applicationKey() {
return config.getProperty("metrics.datadog.applicationKey", "");
}
@Override
public String uri() {
return config.getProperty("metrics.datadog.uri", "https://api.datadoghq.com");
}
@Override
public Duration step() {
String stepSeconds = config.getProperty("metrics.datadog.step");
if (stepSeconds != null && !stepSeconds.isBlank()) {
try {
return Duration.ofSeconds(Long.parseLong(stepSeconds));
} catch (NumberFormatException ignored) {
}
}
return Duration.ofSeconds(10);
}
@Override
public String get(String key) {
return config.getProperty("metrics.datadog." + key);
}
};
return DatadogMeterRegistry.builder(datadogConfig)
.clock(Clock.SYSTEM)
.build();
}
}
The resource file com.gigaspaces.metrics.micrometer.GsMeterRegistryProvider should contain:
com.gigaspaces.example.metrics.datadog.DatadogRegistryProvider
In-Memory Data Grid - achieve unparalleled speed, persistence, and accuracy.