Skip to content

Commit

Permalink
fix default Prometheus port
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo committed May 18, 2022
1 parent 47a5fb2 commit 6748870
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions examples/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ std::unique_ptr<metrics_sdk::MetricExporter> exporter{
OpenTelemetry `PrometheusExporter` will export
data via the endpoint defined by
`metrics_exporter::PrometheusExporterOptions::url`,
which is `http://localhost:8080/` by default.
which is `http://localhost:9464/` by default.

```mermaid
graph LR
subgraph SDK
MeterProvider
MetricReader[PeriodicExportingMetricReader]
PrometheusExporter["PrometheusExporter<br/>(http://localhost:8080/)"]
PrometheusExporter["PrometheusExporter<br/>(http://localhost:9464/)"]
end
subgraph API
Expand Down Expand Up @@ -76,7 +76,7 @@ while (true)
### Check results in the browser

Start the application and keep it running. Now we should be able to see the
metrics at [http://localhost:8080/metrics](http://localhost:9464/metrics) from a
metrics at [http://localhost:9464/metrics](http://localhost:9464/metrics) from a
web browser:

![Browser UI](https://user-images.githubusercontent.com/71217171/168492500-12bd1c99-33ab-4515-a294-17bc349b5d13.png)
Expand Down Expand Up @@ -108,11 +108,11 @@ alerting:
timeout: 5s
api_version: v2
static_configs:
- targets: [localhost:8080]
- targets: [localhost:9464]
scrape_configs:
- job_name: otel
static_configs:
- targets: ['localhost:8080']
- targets: ['localhost:9464']
```
### Start Prometheus
Expand Down Expand Up @@ -194,7 +194,7 @@ subgraph Prometheus
PrometheusDatabase
end
PrometheusExporter["PrometheusExporter<br/>(listening at #quot;http://localhost:8080/#quot;)"] -->|HTTP GET| PrometheusScraper{{"Prometheus scraper<br/>(polling #quot;http://localhost:8080/metrics#quot; every 10 seconds)"}}
PrometheusExporter["PrometheusExporter<br/>(listening at #quot;http://localhost:9464/#quot;)"] -->|HTTP GET| PrometheusScraper{{"Prometheus scraper<br/>(polling #quot;http://localhost:9464/metrics#quot; every 10 seconds)"}}
PrometheusScraper --> PrometheusDatabase[("Prometheus TSDB (time series database)")]
PrometheusDatabase -->|http://localhost:9090/graph| PrometheusUI["Browser<br/>(Prometheus Dashboard)"]
PrometheusDatabase -->|http://localhost:9090/api/| Grafana[Grafana Server]
Expand Down
4 changes: 2 additions & 2 deletions examples/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ alerting:
timeout: 5s
api_version: v2
static_configs:
- targets: [localhost:8080]
- targets: [localhost:9464]
scrape_configs:
- job_name: otel
static_configs:
- targets: ['localhost:8080']
- targets: ['localhost:9464']
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace exporter
namespace metrics
{

inline const std::string GetOtlpDefaultHttpEndpoint()
inline const std::string GetPrometheusDefaultHttpEndpoint()
{
constexpr char kPrometheusEndpointEnv[] = "PROMETHEUS_EXPORTER_ENDPOINT";
constexpr char kPrometheusEndpointDefault[] = "localhost:8080";
constexpr char kPrometheusEndpointDefault[] = "localhost:9464";

auto endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kPrometheusEndpointEnv);
return endpoint.size() ? endpoint : kPrometheusEndpointDefault;
Expand All @@ -43,7 +43,7 @@ inline const std::string GetOtlpDefaultHttpEndpoint()
struct PrometheusExporterOptions
{
// The endpoint the Prometheus backend can collect metrics from
std::string url = GetOtlpDefaultHttpEndpoint();
std::string url = GetPrometheusDefaultHttpEndpoint();
};

class PrometheusExporter : public sdk::metrics::MetricExporter
Expand Down

0 comments on commit 6748870

Please sign in to comment.