-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b75ae
commit d639a06
Showing
11 changed files
with
3,437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#### Prometheus | ||
|
||
As in previous scenarios, you can also use Prometheus and Grafana. | ||
|
||
To use the module, you will need to include the following dependency in your project: | ||
|
||
:::: code-group | ||
::: code-group-item Maven | ||
```xml | ||
<dependency> | ||
<groupId>us.abstracta.jmeter</groupId> | ||
<artifactId>jmeter-java-dsl-prometheus</artifactId> | ||
<version>1.27</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
::: | ||
::: code-group-item Gradle | ||
```groovy | ||
testImplementation 'us.abstracta.jmeter:jmeter-java-dsl-prometheus:1.27' | ||
``` | ||
::: | ||
:::: | ||
|
||
And use provided `prometheusListener()` method like in this example: | ||
|
||
```java | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static us.abstracta.jmeter.javadsl.JmeterDsl.*; | ||
import static us.abstracta.jmeter.javadsl.prometheus.DslPrometheusListener.*; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import org.junit.jupiter.api.Test; | ||
import us.abstracta.jmeter.javadsl.core.TestPlanStats; | ||
|
||
public class PerformanceTest { | ||
|
||
@Test | ||
public void testPerformance() throws IOException { | ||
TestPlanStats stats = testPlan( | ||
threadGroup(2, 10, | ||
httpSampler("http://my.service") | ||
), | ||
prometheusListener() | ||
).run(); | ||
assertThat(stats.overall().sampleTimePercentile99()).isLessThan(Duration.ofSeconds(5)); | ||
} | ||
|
||
} | ||
``` | ||
|
||
As in previous cases, you can to try it locally by running `docker-compose up` inside [this directory](/docs/guide/reporting/real-time/prometheus). After containers are started, you can follow the same steps as in previous scenarios. | ||
|
||
::: warning | ||
Use the provided `docker-compose` settings for local tests only. It uses weak credentials and is not properly configured for production purposes. | ||
::: | ||
|
||
Check [DslPrometheusListener](/jmeter-java-dsl-prometheus/src/main/java/us/abstracta/jmeter/javadsl/prometheus/DslPrometheusListener.java) for details on listener settings. | ||
|
||
Here is an example that shows the default settings used by `prometheusListener`: | ||
|
||
```java | ||
import us.abstracta.jmeter.javadsl.prometheus.DslPrometheusListener.PrometheusMetric; | ||
... | ||
prometheusListener() | ||
.metrics( | ||
PrometheusMetric.responseTime("ResponseTime", "the response time of samplers") | ||
.labels(PrometheusMetric.SAMPLE_LABEL, PrometheusMetric.RESPONSE_CODE) | ||
.quantile(0.75, 0.5) | ||
.quantile(0.95, 0.1) | ||
.quantile(0.99, 0.01) | ||
.maxAge(Duration.ofMinutes(1)), | ||
PrometheusMetric.successRatio("Ratio", "the success ratio of samplers") | ||
.labels(PrometheusMetric.SAMPLE_LABEL, PrometheusMetric.RESPONSE_CODE) | ||
) | ||
.port(9270) | ||
.host("0.0.0.0") | ||
.endWait(Duration.ofSeconds(10)) | ||
... | ||
``` | ||
> Note that the default settings are different from the used JMeter Prometheus Plugin, to allow easier usage and avoid missing metrics at the end of test plan execution. | ||
::: tip | ||
When configuring the `prometheusListener` always consider setting a `endWait` that is greater thant the Prometheus Server configured `scrape_interval` to avoid missing metrics at the end of test plan execution (e.g.: 2x the scrape interval value). | ||
::: |
24 changes: 24 additions & 0 deletions
24
docs/guide/reporting/real-time/prometheus/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
services: | ||
prometheus: | ||
image: prom/prometheus:v2.51.2 | ||
ports: | ||
- '9090:9090' | ||
volumes: | ||
- prometheus-data:/prometheus | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
grafana: | ||
image: grafana/grafana:10.4.2 | ||
ports: | ||
- '3000:3000' | ||
volumes: | ||
- grafana-data:/var/lib/grafana | ||
- ./grafana-provisioning/:/etc/grafana/provisioning | ||
depends_on: | ||
- prometheus | ||
environment: | ||
- GF_SECURITY_ADMIN_USER=admin | ||
- GF_SECURITY_ADMIN_PASSWORD=1234 | ||
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/jmeter.json | ||
volumes: | ||
prometheus-data: | ||
grafana-data: |
6 changes: 6 additions & 0 deletions
6
docs/guide/reporting/real-time/prometheus/grafana-provisioning/dashboards/dashboard.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: 1 | ||
providers: | ||
- name: JMeter Dashboards | ||
allowUiUpdates: true | ||
options: | ||
path: /etc/grafana/provisioning/dashboards |
Oops, something went wrong.