-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
285 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,20 @@ | ||
# Splunk Redis+SignalFX Example | ||
|
||
This example provides a `docker-compose` environment that sends redis data to stdout and sfx. You can change the exporters to your liking by modifying `otel-collector-config.yaml`. | ||
|
||
You'll need to install docker at a minimum. Ensure the following environment variables are properly set: | ||
|
||
1. `REDIS_PASSWORD` (default: `changeme`, see `redis.conf`) | ||
1. `SPLUNK_ACCESS_TOKEN` (for sfx exporter) | ||
1. `SPLUNK_REALM` (for sfx exporter) | ||
1. `SPLUNK_PASSWORD` (for splunk exporter) | ||
|
||
Once you've verified your environment, you can run the example by | ||
|
||
```bash | ||
$> docker-compose up --build | ||
``` | ||
|
||
## Splunk Collector | ||
|
||
Note that you may get an error similar to `{"kind": "exporter", "data_type": "metrics", "name": "splunk_hec/metrics", "error": "Post \"https://splunk_redis:8088/services/collector\": dial tcp 172.21.0.2:8088: connect: connection refused", "interval": "3.877023586s"}` upon first startup. This is likely because the splunk_hec receiver has not fully started yet. Wait until you see the hec receiver output something like `PLAY RECAP *********************************************************************`, and it should work as expected. |
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,50 @@ | ||
version: "3.1" | ||
services: | ||
# Redis instance (the thing we're instrumenting) | ||
redis_db: | ||
container_name: redis_db | ||
image: redis:latest | ||
command: redis-server /etc/redis/redis.conf | ||
volumes: | ||
- "./redis.conf:/etc/redis/redis.conf" | ||
ports: | ||
- "6379:6379" | ||
- "6329:6329" | ||
#splunk: | ||
# image: splunk/splunk:latest | ||
# container_name: splunk_redis | ||
# 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 | ||
otelcollector: | ||
# if you want to run with the currently released image, | ||
#image: quay.io/signalfx/splunk-otel-collector:latest | ||
# if building locally via `make docker-otel`, | ||
image: otelcol:latest | ||
container_name: otelcollector-redis-receiver-example | ||
environment: | ||
- SPLUNK_ACCESS_TOKEN=${SPLUNK_ACCESS_TOKEN} | ||
- SPLUNK_REALM=${SPLUNK_REALM} | ||
- SPLUNK_PASSWORD=changeme | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
command: ["--config=/etc/otel-collector-config.yaml", "--set=service.telemetry.logs.level=debug"] | ||
volumes: | ||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml | ||
ports: | ||
- "18088:8088" | ||
- "8888:8888" | ||
depends_on: | ||
- redis_db | ||
# - splunk |
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,58 @@ | ||
receivers: | ||
redis: | ||
# For more information on redis specific configuration, see | ||
# See https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/redisreceiver | ||
endpoint: "redis_db:6379" | ||
collection_interval: 10s | ||
password: ${REDIS_PASSWORD} | ||
metrics: | ||
redis.role: | ||
enabled: true | ||
redis.cmd.calls: | ||
enabled: true | ||
extensions: | ||
health_check: | ||
endpoint: 0.0.0.0:13133 | ||
processors: | ||
batch: | ||
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_redis:8088/services/collector" | ||
# 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 | ||
tls: | ||
# 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 | ||
signalfx: | ||
# https://aws-otel.github.io/docs/partners/splunk#configuring-signalfx-exporter | ||
access_token: ${SPLUNK_ACCESS_TOKEN} | ||
realm: "${SPLUNK_REALM}" | ||
logging: | ||
loglevel: debug | ||
service: | ||
telemetry: | ||
metrics: | ||
address: ":8888" | ||
pipelines: | ||
metrics/sfx: | ||
receivers: [redis] | ||
processors: [batch] | ||
exporters: [signalfx] | ||
metrics/logging: | ||
receivers: [redis] | ||
processors: [batch] | ||
exporters: [logging] | ||
#metrics/splunk: | ||
# receivers: [redis] | ||
# processors: [batch] | ||
# 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,4 @@ | ||
bind * -::* | ||
port 6379 | ||
protected-mode no | ||
requirepass changeme |
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 @@ | ||
splunk: | ||
conf: | ||
indexes: | ||
directory: /opt/splunk/etc/apps/search/local | ||
content: | ||
metrics: | ||
coldPath: $SPLUNK_DB/metrics/colddb | ||
datatype: metric | ||
homePath: $SPLUNK_DB/metrics/db | ||
maxTotalDataSizeMB: 512000 | ||
thawedPath: $SPLUNK_DB/metrics/thaweddb |
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
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
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
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
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,37 @@ | ||
// Copyright Splunk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build integration || hi | ||
|
||
package tests | ||
|
||
import ( | ||
"path" | ||
"testing" | ||
|
||
"github.com/signalfx/splunk-otel-collector/tests/testutils" | ||
) | ||
|
||
func TestRedisReceiverProvidesAllMetrics(t *testing.T) { | ||
server := testutils.NewContainer().WithContext(path.Join(".", "testdata", "server")).WithExposedPorts("6379:6379").WithName("redis-server").WillWaitForPorts("6379").WillWaitForLogs("Ready to accept connections") | ||
containers := []testutils.Container{server} | ||
testutils.AssertAllMetricsReceived(t, "all.yaml", "all_metrics_config.yaml", containers) | ||
} | ||
|
||
func TestRedisReceiverProvidesAllMetricsWithServer(t *testing.T) { | ||
server := testutils.NewContainer().WithContext(path.Join(".", "testdata", "server")).WithExposedPorts("6379:6379").WithNetworks("redis_network").WithName("redis-server").WillWaitForLogs("Ready to accept connections") | ||
client := testutils.NewContainer().WithContext(path.Join(".", "testdata", "client")).WithName("redis-client").WithNetworks("redis_network").WillWaitForLogs("redis client started") | ||
containers := []testutils.Container{server, client} | ||
testutils.AssertAllMetricsReceived(t, "all.yaml", "all_metrics_config.yaml", containers) | ||
} |
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,14 @@ | ||
receivers: | ||
redis: | ||
endpoint: 0.0.0.0:6379 | ||
exporters: | ||
otlp: | ||
endpoint: "${OTLP_ENDPOINT}" | ||
insecure: true | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: | ||
- redis | ||
exporters: [otlp] |
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,5 @@ | ||
FROM redis | ||
|
||
COPY init.sh /usr/local/bin/init.sh | ||
|
||
CMD ["init.sh"] |
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 @@ | ||
#!/bin/bash | ||
|
||
echo "Beginning redis client" | ||
|
||
# Checking for the connection, return "PONG" if succeded | ||
redis-cli -h redis-server ping | ||
|
||
# Setting key value pair in the redis server from the client, return "OK" if succeded | ||
redis-cli -h redis-server set tempkey tempvalue | ||
|
||
echo "redis client started" |
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,60 @@ | ||
resource_metrics: | ||
- attributes: | ||
redis.version: <ANY> | ||
scope_metrics: | ||
- instrumentation_scope: | ||
name: otelcol/redisreceiver | ||
version: <ANY> | ||
metrics: | ||
- name: redis.uptime | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.cpu.time | ||
type: DoubleMonotonicCumulativeSum | ||
- name: redis.clients.connected | ||
type: IntNonmonotonicCumulativeSum | ||
- name: redis.clients.max_input_buffer | ||
type: IntGauge | ||
- name: redis.clients.max_output_buffer | ||
type: IntGauge | ||
- name: redis.clients.blocked | ||
type: IntNonmonotonicCumulativeSum | ||
- name: redis.keys.expired | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.keys.evicted | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.connections.rejected | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.memory.used | ||
type: IntGauge | ||
- name: redis.memory.rss | ||
type: IntGauge | ||
- name: redis.memory.peak | ||
type: IntGauge | ||
- name: redis.memory.lua | ||
type: IntGauge | ||
- name: redis.memory.fragmentation_ratio | ||
type: DoubleGauge | ||
- name: redis.rdb.changes_since_last_save | ||
type: IntNonmonotonicCumulativeSum | ||
- name: redis.commands | ||
type: IntGauge | ||
- name: redis.connections.received | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.commands.processed | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.net.input | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.net.output | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.keyspace.hits | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.keyspace.misses | ||
type: IntMonotonicCumulativeSum | ||
- name: redis.latest_fork | ||
type: IntGauge | ||
- name: redis.slaves.connected | ||
type: IntNonmonotonicCumulativeSum | ||
- name: redis.replication.backlog_first_byte_offset | ||
type: IntGauge | ||
- name: redis.replication.offset | ||
type: IntGauge |
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 @@ | ||
FROM redis |