Hi @all!
I'm new in the prooooometheus world and just tried to use it in my spring boot project.
What I did:
Add prometheus to pom:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>0.1.0</version>
</dependency>
Activate it via annotation:
(Class contained more code in between my tries...)
@Configuration
@EnablePrometheusEndpoint
public class PrometheusConfiguration {}
Download and unpack prometheus:
prometheus-2.0.0-rc.2.linux-amd64.tar.gz
Adapt prometheus.yml
#...
scrape_configs:
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
basic_auth:
username: admin
password: s3cr3t
static_configs:
- targets: ['localhost:8080']
Run spring-boot app and prometheus.
Targets-Web-Page
http://localhost:9090/targets gives me:
prometheus (0/1 up)
Endpoint State Labels Last Scrape Error
http://localhost:8080/metrics down instance="localhost:8080" 14.734s ago no token found
Console output of prometeus gives me:
level=warn ts=2017-10-27T13:20:50.25392254Z caller=scrape.go:673 component="target manager" scrape_pool=prometheus target=
http://localhost:8080/metrics msg="append failed" err="no token found"
Content of /metrics is:
{"mem":491665,"mem.free":274533,"processors":4,"instance.uptime":940532,"uptime":944976,"systemload.average":0.04,"heap.committed":424960,"heap.init":129024,"heap.used":150426,"heap":1817088,"nonheap.committed":68000,"nonheap.init":2496,"nonheap.used":66705,"nonheap":0,"threads.peak":25,"threads.daemon":21,"threads.totalStarted":29,"threads":23,"classes":9983,"classes.loaded":9983,"classes.unloaded":0,"gc.ps_scavenge.count":9,"gc.ps_scavenge.time":97,"gc.ps_marksweep.count":2,"gc.ps_marksweep.time":107,"httpsessions.max":-1,"httpsessions.active":63,"datasource.primary.active":0,"datasource.primary.usage":0.0,"gauge.response.metrics":398.0,"gauge.response.star-star.favicon.ico":3.0,"counter.status.200.star-star.favicon.ico":2,"counter.status.200.metrics":62,"counter.status.401.metrics":2}
Any ideas? :-|
Greetings!
Boris