Skip to content

Commit 266fe80

Browse files
committed
feat: configurado scrape
1 parent 04af88b commit 266fe80

File tree

5 files changed

+64
-23
lines changed

5 files changed

+64
-23
lines changed

Demo.API/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void Main(string[] args)
1818
{
1919
Metrics = AppMetrics.CreateDefaultBuilder()
2020
.OutputMetrics.AsPrometheusPlainText()
21-
.OutputMetrics.AsPrometheusProtobuf()
21+
// .OutputMetrics.AsPrometheusProtobuf()
2222
.Build();
2323

2424

@@ -54,8 +54,8 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args)
5454
{
5555
options.EndpointOptions = endpointsOptions =>
5656
{
57-
endpointsOptions.MetricsTextEndpointOutputFormatter = Metrics.OutputMetricsFormatters.OfType<MetricsPrometheusTextOutputFormatter>().First();
58-
endpointsOptions.MetricsEndpointOutputFormatter = Metrics.OutputMetricsFormatters.OfType<MetricsPrometheusProtobufOutputFormatter>().First();
57+
// endpointsOptions.MetricsTextEndpointOutputFormatter = Metrics.OutputMetricsFormatters.OfType<MetricsPrometheusTextOutputFormatter>().First();
58+
endpointsOptions.MetricsEndpointOutputFormatter = Metrics.OutputMetricsFormatters.OfType<MetricsPrometheusTextOutputFormatter>().First();
5959
};
6060
})
6161
.UseStartup<Startup>();

Demo.Worker/Demo.Worker.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
1414
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="2.2.0" />
15-
<PackageReference Include="Super.Package.Configuration.ConfigServer.Abstractions" Version="1.0.2" />
1615
<PackageReference Include="System.Configuration.Abstractions" Version="2.0.2.45" />
1716
</ItemGroup>
1817

docker-compose.yml

+23-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,26 @@ services:
7878
- "15672:15672"
7979
environment:
8080
RABBITMQ_DEFAULT_USER: guest
81-
RABBITMQ_DEFAULT_PASS: guest
81+
RABBITMQ_DEFAULT_PASS: guest
82+
83+
prom:
84+
image: quay.io/prometheus/prometheus:v2.0.0
85+
volumes:
86+
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
87+
command: "--config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus"
88+
ports:
89+
- 9090:9090
90+
depends_on:
91+
- exporter
92+
exporter:
93+
image: prom/node-exporter:latest
94+
ports:
95+
- "9100:9100"
96+
grafana:
97+
image: grafana/grafana
98+
ports:
99+
- "3000:3000"
100+
environment:
101+
- GF_INSTALL_PLUGINS=grafana-piechart-panel
102+
depends_on:
103+
- prom

prometheus/docker-compose.yml

-11
This file was deleted.

prometheus/prometheus.yml

+38-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,40 @@
1-
# prometheus.yml
1+
# my global config
22
global:
3-
scrape_interval: 5s
4-
external_labels:
5-
monitor: 'my-monitor'
3+
scrape_interval: 15s # By default, scrape targets every 15 seconds.
4+
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
5+
# scrape_timeout is set to the global default (10s).
6+
7+
# Attach these labels to any time series or alerts when communicating with
8+
# external systems (federation, remote storage, Alertmanager).
9+
external_labels:
10+
monitor: 'codelab-monitor'
11+
12+
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
13+
rule_files:
14+
# - "first.rules"
15+
# - "second.rules"
16+
17+
# A scrape configuration containing exactly one endpoint to scrape:
18+
# Here it's Prometheus itself.
619
scrape_configs:
7-
- job_name: 'prometheus'
8-
target_groups:
9-
- targets: ['localhost:9090']
20+
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
21+
- job_name: 'prometheus'
22+
23+
# Override the global default and scrape targets from this job every 5 seconds.
24+
scrape_interval: 5s
25+
26+
# metrics_path defaults to '/metrics'
27+
# scheme defaults to 'http'.
28+
29+
static_configs:
30+
- targets: ['localhost:9090']
31+
32+
- job_name: "node"
33+
scrape_interval: "15s"
34+
static_configs:
35+
- targets: ['exporter:9100']
36+
37+
- job_name: "webapi"
38+
scrape_interval: 5s
39+
static_configs:
40+
- targets: ['web']

0 commit comments

Comments
 (0)