# The `metrics` Module

This module contains two applications:

- The metrics server
- The metric processing pipeline

## `cmd/scrape_gateway/main.go` (**_DEPRECATED_**)

A server acting as metric pull endpoints for Prometheus scrape request.

## `cmd/push_pipeline/main.go`

A streaming pipeline for processing metrics. 

It can push data to third-party monitoring platforms (such as "Datadog.com", [prometheus remote write](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/prometheusremotewriteexporter)),
or serve as a [prometheus scraping target](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/prometheusexporter).

### Run pipeline locally

Refer to `./build/pipeline/Dockerfile`. You need pass two config paths to the command:

- Dbaas central config: get it from configmap in dev-base k8s. 
  
  - Add a field in downloaded config: `server.thanosAddr: http://127.0.0.1:9090`.
  - Start a port-forwarding service with `kubectl port-forward -n monitoring service/thanos-query 9090 9090` .

- Otel collector config: refer to examples under `./example/push_pipeline/`.

Then you can start pipeline with `main.go` directly.
