-
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.
- Loading branch information
Showing
14 changed files
with
209 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,15 @@ | ||
# 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) | ||
|
||
Once you've verified your environment, you can run the example by | ||
|
||
```bash | ||
$> docker-compose up --build | ||
``` |
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,31 @@ | ||
version: "3.8" | ||
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" | ||
# OpenTelemetry Collector | ||
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} | ||
- 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 |
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,32 @@ | ||
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} | ||
extensions: | ||
health_check: | ||
endpoint: 0.0.0.0:13133 | ||
processors: | ||
batch: | ||
exporters: | ||
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] |
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
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
28 changes: 28 additions & 0 deletions
28
tests/receivers/adopted/redisreceiver/redisreceiver_test.go
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,28 @@ | ||
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) | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/receivers/adopted/redisreceiver/testdata/all_metrics_config.yaml
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] |
5 changes: 5 additions & 0 deletions
5
tests/receivers/adopted/redisreceiver/testdata/client/Dockerfile
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"] |
11 changes: 11 additions & 0 deletions
11
tests/receivers/adopted/redisreceiver/testdata/client/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" |
57 changes: 57 additions & 0 deletions
57
tests/receivers/adopted/redisreceiver/testdata/resource_metrics/all.yaml
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,57 @@ | ||
resource_metrics: | ||
- instrumentation_library_metrics: | ||
- instrumentation_library: | ||
name: otelcol/redis | ||
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 |
1 change: 1 addition & 0 deletions
1
tests/receivers/adopted/redisreceiver/testdata/server/Dockerfile
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 |