-
Notifications
You must be signed in to change notification settings - Fork 169
Adds redis and an example to run it #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,16 @@ | ||
# Redis Infrastructure Monitoring 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 | ||
``` | ||
|
This file contains hidden or 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.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" | ||
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 | ||
hughesjj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 hidden or 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 @@ | ||
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: | ||
signalfx: | ||
# to configure, see https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/signalfxexporter | ||
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can write this as:
you don't have to and in effect this is going to define the exact same output, but just in case that wasn't an explicit set up. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.