Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcosbarbero/micrometer-try-out
https://github.com/marcosbarbero/micrometer-try-out
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/marcosbarbero/micrometer-try-out
- Owner: marcosbarbero
- Created: 2018-07-28T20:48:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-31T11:54:23.000Z (over 6 years ago)
- Last Synced: 2024-10-15T09:07:08.626Z (3 months ago)
- Language: Java
- Size: 217 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sample Tryout Micrometer App
---It's just a toy spring boot tryout micrometer application where I'm trying to find the request
throughput and latency.### Tech Stack
* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
* [Maven](https://maven.apache.org/)
* [Spring Boot 2](https://spring.io/projects/spring-boot)
* [Spring Boot Actuator](https://spring.io/projects/spring-boot)
* [Micrometer](https://micrometer.io/)
* [Prometheus](https://prometheus.io/)
* [Grafana](https://grafana.com/)
* [Gatling](https://gatling.io/)
* [Docker](http://docker.io/)### Design Overview
The application is configured to export [histogram](https://github.com/micrometer-metrics/micrometer-docs/blob/master/src/docs/concepts/histogram-quantiles.adoc)
metrics by [Micrometer](https://micrometer.io/) where [Prometheus](https://prometheus.io/) keep listening to
`/actuator/prometheus` endpoint and [Grafana](https://grafana.com/) uses [Prometheus](https://prometheus.io/) as datasource,
with that information we can create dashboards to check the application's throughput and latency.>Sorry there's image for now
Spring Boot → Micrometer → Prometheus → Grafana
### Build & Run
#### Spring Boot App
To run the sample app just run the following command:
```bash
$ ./mvnw spring-boot:run
```The app will be available at http://localhost:8080 and it contains only a single endpoint `/api/sample` in which
returns only a random `uuid`.Sample request:
```bash
$ curl -i localhost:8080/api/sampleHTTP/1.1 200
Content-Type: text/plain;charset=UTF-8
Content-Length: 36
Date: Tue, 31 Jul 2018 09:48:11 GMT66a20e40-2795-4666-b470-634b8768da3b
```#### Prometheus
For this example, I'm running Prometheus using docker, if you are going to do the same just edit
the file `./monitor/prometheus/prometheus.yml` adding your own `IP` address, or the `IP` where you are running the
app.**IMPORTANT**: *It's mandatory to change the IP in the following configuration otherwise [Prometheus](https://prometheus.io/)
can not pull the data from the application.*```yaml
global:
scrape_interval: 15s
evaluation_interval: 15sscrape_configs:
- job_name: 'spring'
scrape_interval: 5s
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['192.168.178.143:8080'] #Provide your IP here
```If you are running everything locally you can use `localhost` as `IP`.
#### Grafana
As for Prometheus I'm running Grafana using docker and here you can find two files:
* `./monitor/grafana/datasource.yml`
* Configures Prometheus as datasource, you can also do it manually in case you have a
standalone Grafana instance running.
* `./monitor/grafana/dashboard.yml`
* Contains the configuration pointing to the location where the dashboards are stored.#### Run Prometheus & Grafana (Docker)
Everything related to Prometheus and [Grafana](https://grafana.com/) is properly configured using
[Docker Compose](https://docs.docker.com/compose/), just run:```bash
$ docker-compose up -d
```Once it finishes you'll be able to access the [Grafana](https://grafana.com/) panel at http://localhost:3000,
for the first login you might need to configure and username and password, the default value for both is `admin`.### Load Test - Gatling
Now that everything is settled you can just run the Gatling script for a load test using the following command:
```bash
$ mvn gatling:test
```### Reports
#### Throughput
![Throughput](./assets/throughput.png)
#### Latency
![Latency](./assets/latency.png)