Skip to content
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

[Cortex] Example project #238

Merged
merged 5 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions exporters/metric/cortex/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cortex Exporter Example

This example exports several metrics to a [Cortex](https://cortexmetrics.io/) instance and displays
them in [Grafana](https://grafana.com/).

## Requirements

- [Docker Compose](https://docs.docker.com/compose/) installed

## Instructions

1. Run the docker container with the following command

```bash
docker-compose up -d
```

2. Log in to the Grafana instance running at [http://localhost:3000](http://localhost:3000). The
login credentials are admin/admin.

3. Add Cortex as a data source by creating a new Prometheus data source using
[http://localhost:9009/api/prom/](http://localhost:9009/api/prom/) as the endpoint.

4. View collected metrics in Grafana.

5. Shut down the services when you're finished with the example

```bash
docker-compose down
```
20 changes: 20 additions & 0 deletions exporters/metric/cortex/example/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright The OpenTelemetry Authors
#
# 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.

url: http://host.docker.internal:9009/api/prom/push
remote_timeout: 30s
push_interval: 2s
name: Test
headers:
X-Scope-OrgID: 5
connorlindsey marked this conversation as resolved.
Show resolved Hide resolved
99 changes: 99 additions & 0 deletions exporters/metric/cortex/example/cortexConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# This Cortex Config is copied from the Cortex Project documentation
# Source: https://github.com/cortexproject/cortex/blob/master/docs/configuration/single-process-config.yaml

# Configuration for running Cortex in single-process mode.
# This configuration should not be used in production.
# It is only for getting started and development.

# Disable the requirement that every request to Cortex has a
# X-Scope-OrgID header. `fake` will be substituted in instead.
auth_enabled: false

server:
http_listen_port: 9009

# Configure the server to allow messages up to 100MB.
grpc_server_max_recv_msg_size: 104857600
grpc_server_max_send_msg_size: 104857600
grpc_server_max_concurrent_streams: 1000

distributor:
shard_by_all_labels: true
pool:
health_check_ingesters: true

ingester_client:
grpc_client_config:
# Configure the client to allow messages up to 100MB.
max_recv_msg_size: 104857600
max_send_msg_size: 104857600
use_gzip_compression: true

ingester:
# We want our ingesters to flush chunks at the same time to optimise
# deduplication opportunities.
spread_flushes: true
chunk_age_jitter: 0

walconfig:
wal_enabled: true
recover_from_wal: true
wal_dir: /tmp/cortex/wal

lifecycler:
# The address to advertise for this ingester. Will be autodiscovered by
# looking up address on eth0 or en0; can be specified if this fails.
# address: 127.0.0.1

# We want to start immediately and flush on shutdown.
join_after: 0
min_ready_duration: 0s
final_sleep: 0s
num_tokens: 512
tokens_file_path: /tmp/cortex/wal/tokens

# Use an in memory ring store, so we don't need to launch a Consul.
ring:
kvstore:
store: inmemory
replication_factor: 1

# Use local storage - BoltDB for the index, and the filesystem
# for the chunks.
schema:
configs:
- from: 2019-07-29
store: boltdb
object_store: filesystem
schema: v10
index:
prefix: index_
period: 1w

storage:
boltdb:
directory: /tmp/cortex/index

filesystem:
directory: /tmp/cortex/chunks

delete_store:
store: boltdb

purger:
object_store_type: filesystem

frontend_worker:
# Configure the frontend worker in the querier to match worker count
# to max_concurrent on the queriers.
match_max_concurrent: true

# Configure the ruler to scan the /tmp/cortex/rules directory for prometheus
# rules: https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#recording-rules
ruler:
enable_api: true
enable_sharding: false
storage:
type: local
local:
directory: /tmp/cortex/rules
35 changes: 35 additions & 0 deletions exporters/metric/cortex/example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright The OpenTelemetry Authors
#
# 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.

version: "3"

services:
app:
image: golang:1.14-alpine
volumes:
- .:/app
working_dir: /app
command: go run main.go
cortex:
image: quay.io/cortexproject/cortex:v1.3.0-rc.1
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
command:
- -config.file=./config/cortexConfig.yml
volumes:
- ./cortexConfig.yml:/config/cortexConfig.yml:ro
ports:
- 9009:9009
grafana:
image: grafana/grafana:latest
ports:
- 3000:3000
11 changes: 11 additions & 0 deletions exporters/metric/cortex/example/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module go.opentelemetry.io/contrib/exporters/metric/cortex/example

go 1.14

require (
go.opentelemetry.io/contrib/exporters/metric/cortex v0.10.1
go.opentelemetry.io/contrib/exporters/metric/cortex/utils v0.10.1
go.opentelemetry.io/otel v0.10.0
go.opentelemetry.io/otel/sdk v0.10.0
gopkg.in/yaml.v2 v2.2.5 // indirect
)
Loading