forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prometheus federation example (open-telemetry#57)
* Add an example showing how to use the OpenTelemetry collector to collect metrics from a Prometheus server * Fix imports * Remove mention of corda, use app as app name * remove the sleep statement since we rely on the ticker
- Loading branch information
Showing
10 changed files
with
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Prometheus Federation Endpoint Example | ||
|
||
This example showcases how the agent works with Splunk Enterprise and an existing Prometheus deployment. | ||
|
||
The example runs as a Docker Compose deployment. The collector can be configured to send various metrics to Splunk Enterprise. | ||
|
||
Splunk is configured to receive data from the OpenTelemetry Collector using the HTTP Event collector. To learn more about HEC, visit [our guide](https://dev.splunk.com/enterprise/docs/dataapps/httpeventcollector/). | ||
|
||
To deploy the example, check out this git repository, open a terminal and in this directory type: | ||
```bash | ||
$> docker-compose up --build | ||
``` | ||
|
||
Splunk will become available on port 18000. You can login on [http://localhost:18000](http://localhost:18000) with `admin` and `changeme`. | ||
|
||
Once logged in, visit the [analytics workspace](http://localhost:18000/en-US/app/search/analytics_workspace) to see which metrics are sent by the OpenTelemetry Collector. | ||
|
||
Additionally, you can consult the [Prometheus UI](http://localhost:9090) to see the metric data collected from the sample go program. | ||
|
||
# Diagram of the deployment | ||
|
||
![Diagram](diagram.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
version: "3" | ||
services: | ||
# Sample Go application producing counter metrics. | ||
prom-counter: | ||
container_name: prom-counter | ||
build: | ||
context: prom-counter | ||
restart: always | ||
# The Prometheus server: | ||
prometheus: | ||
image: prom/prometheus | ||
container_name: prometheus | ||
ports: | ||
- 9090:9090 | ||
volumes: | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
# Splunk Enterprise server: | ||
splunk: | ||
image: splunk/splunk:latest | ||
container_name: splunk | ||
environment: | ||
- SPLUNK_START_ARGS=--accept-license | ||
- SPLUNK_HEC_TOKEN=00000000-0000-0000-0000-0000000000000 | ||
- SPLUNK_PASSWORD=changeme | ||
ports: | ||
- 18000:8000 | ||
healthcheck: | ||
test: ['CMD', 'curl', '-f', 'http://localhost:8000'] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 20 | ||
volumes: | ||
- ./splunk.yml:/tmp/defaults/default.yml | ||
- /opt/splunk/var | ||
- /opt/splunk/etc | ||
# OpenTelemetry Collector | ||
otelcollector: | ||
image: quay.io/signalfx/splunk-otel-collector:0.4.0 | ||
container_name: otelcollector | ||
command: ["--config=/etc/otel-collector-config.yml", "--log-level=DEBUG"] | ||
volumes: | ||
- ./otel-collector-config.yml:/etc/otel-collector-config.yml | ||
depends_on: | ||
- splunk | ||
- prometheus |
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,54 @@ | ||
receivers: | ||
prometheus_simple: | ||
collection_interval: 10s | ||
# the federation endpoint: | ||
# Read more about it here: https://prometheus.io/docs/prometheus/latest/federation/ | ||
# You can query the federation with PromQL, encoded as part of the query string. | ||
endpoint: prometheus:9090 | ||
metrics_path: /federate | ||
params: | ||
match[]: '{job="counter"}' | ||
otlp: | ||
protocols: | ||
grpc: | ||
|
||
exporters: | ||
splunk_hec/metrics: | ||
# Splunk HTTP Event Collector token. | ||
token: "00000000-0000-0000-0000-0000000000000" | ||
# URL to a Splunk instance to send data to. | ||
endpoint: "https://splunk:8088/services/collector" | ||
# Optional Splunk source: https://docs.splunk.com/Splexicon:Source | ||
source: "app:metrics" | ||
# Optional Splunk source type: https://docs.splunk.com/Splexicon:Sourcetype | ||
sourcetype: "prometheus" | ||
# Splunk index, optional name of the Splunk index targeted. | ||
index: "metrics" | ||
# Maximum HTTP connections to use simultaneously when sending data. Defaults to 100. | ||
max_connections: 20 | ||
# Whether to disable gzip compression over HTTP. Defaults to false. | ||
disable_compression: false | ||
# HTTP timeout when sending data. Defaults to 10s. | ||
timeout: 10s | ||
# Whether to skip checking the certificate of the HEC endpoint when sending data over HTTPS. Defaults to false. | ||
# For this demo, we use a self-signed certificate on the Splunk docker instance, so this flag is set to true. | ||
insecure_skip_verify: true | ||
|
||
processors: | ||
batch: | ||
queued_retry: | ||
|
||
extensions: | ||
health_check: | ||
pprof: | ||
endpoint: :1888 | ||
zpages: | ||
endpoint: :55679 | ||
|
||
service: | ||
extensions: [pprof, zpages, health_check] | ||
pipelines: | ||
metrics: | ||
receivers: [prometheus_simple] | ||
processors: [batch, queued_retry] | ||
exporters: [splunk_hec/metrics] |
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,12 @@ | ||
FROM golang:1.14-stretch | ||
|
||
WORKDIR /go/src/app | ||
|
||
COPY go.mod . | ||
COPY main.go . | ||
|
||
RUN go get | ||
|
||
RUN go build | ||
|
||
CMD /go/src/app/app |
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,11 @@ | ||
module app | ||
|
||
go 1.14 | ||
|
||
require ( | ||
go.opentelemetry.io/otel v0.15.0 | ||
go.opentelemetry.io/otel/exporters/metric/prometheus v0.15.0 | ||
go.opentelemetry.io/otel/exporters/otlp v0.15.0 | ||
go.opentelemetry.io/otel/sdk v0.15.0 | ||
go.uber.org/zap v1.16.0 | ||
) |
Oops, something went wrong.