de.inoxio:spring-cloudwatch-metrics

A java-spring library to push metrics to cloudwatch

Лицензия

Лицензия

Категории

Категории

Metrics Тестирование приложения и мониторинг Monitoring
Группа

Группа

de.inoxio
Идентификатор

Идентификатор

spring-cloudwatch-metrics
Последняя версия

Последняя версия

1.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

de.inoxio:spring-cloudwatch-metrics
A java-spring library to push metrics to cloudwatch
Ссылка на сайт

Ссылка на сайт

https://github.com/inoxio/spring-cloudwatch-metrics
Система контроля версий

Система контроля версий

http://github.com/inoxio/spring-cloudwatch-metrics/tree/master

Скачать spring-cloudwatch-metrics

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/de.inoxio/spring-cloudwatch-metrics/ -->
<dependency>
    <groupId>de.inoxio</groupId>
    <artifactId>spring-cloudwatch-metrics</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/de.inoxio/spring-cloudwatch-metrics/
implementation 'de.inoxio:spring-cloudwatch-metrics:1.2.0'
// https://jarcasting.com/artifacts/de.inoxio/spring-cloudwatch-metrics/
implementation ("de.inoxio:spring-cloudwatch-metrics:1.2.0")
'de.inoxio:spring-cloudwatch-metrics:jar:1.2.0'
<dependency org="de.inoxio" name="spring-cloudwatch-metrics" rev="1.2.0">
  <artifact name="spring-cloudwatch-metrics" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.inoxio', module='spring-cloudwatch-metrics', version='1.2.0')
)
libraryDependencies += "de.inoxio" % "spring-cloudwatch-metrics" % "1.2.0"
[de.inoxio/spring-cloudwatch-metrics "1.2.0"]

Зависимости

runtime (3)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter jar
org.springframework.boot : spring-boot-starter-json jar
software.amazon.awssdk : cloudwatch jar 2.10.72

Модули Проекта

Данный проект не имеет модулей.

spring-cloudwatch-metrics

A java-spring library to push metrics to cloudwatch

If you have any questions please open an issue ticket!

Usage

Add this to your build.gradle.kts

dependencies {
    implementation("de.inoxio:spring-cloudwatch-metrics:1.1.0")
}

Inject the CloudwatchDAO from your service as usual:

@Service
public class SomeServiceImpl implements SomeService {
    private final CloudwatchDAO cloudwatchDAO;
    
    @Autowired
    public SomeServiceImpl(final CloudwatchDAO cloudwatchDAO) {
        notNull(cloudwatchDAO, "CloudwatchDAO must not be null!");
        this.cloudwatchDAO = cloudwatchDAO;
    }
    
    /**
    * Optional: If you want to add one or more dimensions to your metrics 
    */
    @PostConstruct
    private void addDimension() {
        cloudwatchDAO.addDimension(dimensionKeyPairBuilder().name("DimensionName")
                                                            .value("DimensionValue")
                                                            .build());
    }
    
    /**
    * To push used heap memory and cpu usage to cloudwatch 
    * have a method like this in your service that calls
    * the CloudwatchDAO. Intended to be invoked by a scheduler.
    */
    public void pushMetrics() {
        final var memoryBean = ManagementFactory.getMemoryMXBean();
        final var operatingSystemBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        
        cloudwatchDAO.pushMetrics(metricKeyPairBuilder().withName("HeapMemoryUsed")
                                                        .withValue(memoryBean.getHeapMemoryUsage().getUsed())
                                                        .build(),
                                  metricKeyPairBuilder().withName("ProcessCpuLoad")
                                                        .withValue(operatingSystemBean.getProcessCpuLoad() * MAX_PERCENT)
                                                        .build());
    }
}

Add the following properties to your project:

aws:
  namespace: Namespace                 # Namespace where the metrics will be pushed to
  metric-prefix: AppPrefix             # All Metrics will get this prefix. Final name will be AppPrefixHeapMemoryUsed
  dashboard-name: some-dashboard-name  # Optional: Set it to the dashboard name you want graphs to be annotated on 
                                       #           server start. It will add a vertical annotation to all graphs with
                                       #           metrics that start with 'metric-prefix'

Release

Change version in build.gradle.kts, README.md and issue:

./gradlew bintrayUpload
de.inoxio

inoxio Quality Services GmbH

Версии библиотеки

Версия
1.2.0
1.1.0
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.1.0