From 259f23b8a648d9725743d40694bf4acdce4cbfb9 Mon Sep 17 00:00:00 2001 From: Jon Schneider Date: Wed, 15 Apr 2020 17:29:55 -0400 Subject: [PATCH] Update grafana/prometheus scripts to latest docker tags, move Spring integration sample to its own sample project --- samples/micrometer-samples-boot2/build.gradle | 9 +------ .../build.gradle | 25 +++++++++++++++++++ .../SpringIntegrationApplication.java | 2 +- scripts/grafana-datasource.yml | 8 ++++++ scripts/grafana.sh | 6 +++-- scripts/prometheus.sh | 3 +-- scripts/prometheus.yml | 16 +----------- scripts/prometheus_rules.yml | 8 ------ settings.gradle | 2 +- 9 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 samples/micrometer-samples-spring-integration/build.gradle rename samples/{micrometer-samples-boot2/src/main/java/io/micrometer/boot2/samples/integration => micrometer-samples-spring-integration/src/main/java/io/micrometer/spring/integration/samples}/SpringIntegrationApplication.java (98%) create mode 100644 scripts/grafana-datasource.yml delete mode 100644 scripts/prometheus_rules.yml diff --git a/samples/micrometer-samples-boot2/build.gradle b/samples/micrometer-samples-boot2/build.gradle index 79e595b729..15836976e4 100644 --- a/samples/micrometer-samples-boot2/build.gradle +++ b/samples/micrometer-samples-boot2/build.gradle @@ -4,12 +4,7 @@ plugins { dependencyManagement { imports { - mavenBom 'org.springframework.boot:spring-boot-dependencies:2.2.0.RELEASE' - } - dependencies { - // not necessary in real Boot 1.5.x apps because reactor is shaded inside the - // published version of micrometer-registry-statsd - dependency 'io.projectreactor:reactor-core:3.2.2.RELEASE' + mavenBom 'org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE' } } @@ -23,8 +18,6 @@ dependencies { implementation('org.springframework.boot:spring-boot-starter-actuator') { exclude group: 'io.micrometer', module: 'micrometer-core' } - implementation 'org.springframework.integration:spring-integration-ws' - implementation 'org.springframework.integration:spring-integration-xml' // For running on Java 9+ runtimeOnly 'javax.xml.soap:javax.xml.soap-api:1.4.0' diff --git a/samples/micrometer-samples-spring-integration/build.gradle b/samples/micrometer-samples-spring-integration/build.gradle new file mode 100644 index 0000000000..bb5690871e --- /dev/null +++ b/samples/micrometer-samples-spring-integration/build.gradle @@ -0,0 +1,25 @@ +plugins { + id "io.spring.dependency-management" version "1.0.3.RELEASE" +} + +dependencyManagement { + imports { + mavenBom 'org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE' + } +} + +dependencies { + implementation project(":micrometer-core") + implementation project(":micrometer-registry-prometheus") + + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation('org.springframework.boot:spring-boot-starter-actuator') { + exclude group: 'io.micrometer', module: 'micrometer-core' + } + implementation 'org.springframework.integration:spring-integration-ws' + implementation 'org.springframework.integration:spring-integration-xml' + + // For running on Java 9+ + runtimeOnly 'javax.xml.soap:javax.xml.soap-api:1.4.0' + runtimeOnly 'com.sun.xml.messaging.saaj:saaj-impl:1.5.1' +} diff --git a/samples/micrometer-samples-boot2/src/main/java/io/micrometer/boot2/samples/integration/SpringIntegrationApplication.java b/samples/micrometer-samples-spring-integration/src/main/java/io/micrometer/spring/integration/samples/SpringIntegrationApplication.java similarity index 98% rename from samples/micrometer-samples-boot2/src/main/java/io/micrometer/boot2/samples/integration/SpringIntegrationApplication.java rename to samples/micrometer-samples-spring-integration/src/main/java/io/micrometer/spring/integration/samples/SpringIntegrationApplication.java index 5a36ac36f3..5c4089669a 100644 --- a/samples/micrometer-samples-boot2/src/main/java/io/micrometer/boot2/samples/integration/SpringIntegrationApplication.java +++ b/samples/micrometer-samples-spring-integration/src/main/java/io/micrometer/spring/integration/samples/SpringIntegrationApplication.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.micrometer.boot2.samples.integration; +package io.micrometer.spring.integration.samples; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/scripts/grafana-datasource.yml b/scripts/grafana-datasource.yml new file mode 100644 index 0000000000..f7522dc91f --- /dev/null +++ b/scripts/grafana-datasource.yml @@ -0,0 +1,8 @@ +apiVersion: 1 + +datasources: +- name: prometheus + type: prometheus + access: direct + url: http://10.200.10.1:9090 + isDefault: true diff --git a/scripts/grafana.sh b/scripts/grafana.sh index 2ace2dc861..9940770a40 100755 --- a/scripts/grafana.sh +++ b/scripts/grafana.sh @@ -1,2 +1,4 @@ -#!/usr/bin/env bash -docker run -i -p 3001:3000 grafana/grafana:5.1.0 \ No newline at end of file +#!/bin/sh +docker run -i -p 3000:3000 \ +-v $(pwd)/grafana-datasource.yml:/etc/grafana/provisioning/datasources/grafana-datasource.yml \ +grafana/grafana:6.7.2 diff --git a/scripts/prometheus.sh b/scripts/prometheus.sh index ffcaa0bb36..5939c4a6ea 100755 --- a/scripts/prometheus.sh +++ b/scripts/prometheus.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash docker run -p 9090:9090 \ -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \ --v $(pwd)/prometheus_rules.yml:/etc/prometheus/prometheus_rules.yml \ -prom/prometheus:v2.2.0 \ No newline at end of file +prom/prometheus:v2.17.1 diff --git a/scripts/prometheus.yml b/scripts/prometheus.yml index 54fee03902..b1b59c764e 100644 --- a/scripts/prometheus.yml +++ b/scripts/prometheus.yml @@ -7,20 +7,6 @@ scrape_configs: static_configs: - targets: ['localhost:9090'] - - job_name: 'pushgateway' - - scrape_interval: 10s - metrics_path: '/metrics' - honor_labels: true - static_configs: - - targets: ['10.200.10.1:9091'] - - - job_name: 'spring-boot1' - - metrics_path: '/prometheus' - static_configs: - - targets: ['10.200.10.1:8080'] - - job_name: 'spring-boot2' metrics_path: '/actuator/prometheus' @@ -28,4 +14,4 @@ scrape_configs: - targets: ['10.200.10.1:8080'] rule_files: - - prometheus_rules.yml \ No newline at end of file + - prometheus_rules.yml diff --git a/scripts/prometheus_rules.yml b/scripts/prometheus_rules.yml deleted file mode 100644 index 2017956202..0000000000 --- a/scripts/prometheus_rules.yml +++ /dev/null @@ -1,8 +0,0 @@ -groups: - - name: latency - interval: 10s - rules: - - record: instance:http_server_requests_seconds_count:rate1m - expr: sum(rate(http_server_requests_seconds_count[75s])) by (instance) - - record: instance:http_server_requests_seconds_sum:rate1m - expr: sum(rate(http_server_requests_seconds_sum[75s])) by (instance) \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 1b53faaefa..7d285ac6c1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,7 @@ rootProject.name = 'micrometer' include 'micrometer-core' include 'micrometer-jersey2' -['core', 'boot2'].each { sample -> +['core', 'boot2', 'spring-integration'].each { sample -> include "micrometer-samples-$sample" project(":micrometer-samples-$sample").projectDir = new File(rootProject.projectDir, "samples/micrometer-samples-$sample") }