Skip to content

Commit

Permalink
code clean
Browse files Browse the repository at this point in the history
Signed-off-by: Weifeng Wang <[email protected]>

Imrpove Alloy integrations

Signed-off-by: Weifeng Wang <[email protected]>

go mod tidy

Update README.md

Update README.md
  • Loading branch information
qclaogui committed Apr 15, 2024
1 parent 30cd419 commit 05fa37c
Show file tree
Hide file tree
Showing 35 changed files with 287 additions and 165 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

A simple command to run Grafana LGTMP Stack in Docker or Kubernetes.

> **NOTE**:
> This project is not intended for production use and is maintained on a best-effort basis.
## Usage

An simple use case `compose.yaml` like so:
Expand Down Expand Up @@ -110,7 +113,7 @@ The easiest way to run project locally is to use docker compose, these instructi
***Prerequisites:*** Make sure that you have Docker and Docker Compose installed
> Note:
> **NOTE**:
> `include` is available in Docker Compose version 2.20 and later, and Docker Desktop version 4.22 and later.
### [Monolithic mode (单体模式)](./docker-compose/monolithic-mode)
Expand Down
18 changes: 10 additions & 8 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ services:
loki:
labels:
<<: *profiles-labels
profiles.grafana.com/service_name: loki
logs.grafana.com/scrape: true
metrics.grafana.com/scrape: true
logs.grafana.com/log-format: json
profiles.grafana.com/service_name: loki
environment:
<<: *jaeger-environment
JAEGER_TAGS: app=loki
Expand All @@ -27,10 +27,10 @@ services:
grafana:
labels:
<<: *profiles-labels
logs.grafana.com/scrape: true
metrics.grafana.com/scrape: true
profiles.grafana.com/service_name: grafana
profiles.grafana.com/port: 6060
metrics.grafana.com/scrape: true
logs.grafana.com/log-format: logfmt
volumes:
- ./monitoring-mixins/pyroscope-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/pyroscope-mixin
- ./monitoring-mixins/loki-mixin/deploy/dashboards_out:/var/lib/grafana/dashboards/loki-mixin
Expand All @@ -45,9 +45,9 @@ services:
tempo:
labels:
<<: *profiles-labels
profiles.grafana.com/service_name: tempo
logs.grafana.com/scrape: true
metrics.grafana.com/scrape: true
logs.grafana.com/log-format: logfmt
profiles.grafana.com/service_name: tempo
depends_on: { minio: { condition: service_healthy }, mimir: { condition: service_healthy } }
environment:
<<: *jaeger-environment
Expand All @@ -57,8 +57,9 @@ services:
mimir:
labels:
<<: *profiles-labels
logs.grafana.com/scrape: true
metrics.grafana.com/scrape: true
profiles.grafana.com/service_name: mimir
logs.grafana.com/log-format: logfmt
environment:
<<: *jaeger-environment
JAEGER_TAGS: app=mimir
Expand All @@ -75,8 +76,9 @@ services:
# override compose.yaml included service pyroscope's labels and environment to enabled traces data collection
pyroscope:
labels:
logs.grafana.com/scrape: true
metrics.grafana.com/scrape: true
logs.grafana.com/log-format: logfmt
profiles.grafana.com/service_name: pyroscope
environment:
<<: *jaeger-environment
JAEGER_TAGS: app=pyroscope
6 changes: 3 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ services:
- ./docker-compose/common/config/pyroscope/gateway_pyroscope.conf:/etc/nginx/templates/gateway_pyroscope.conf.template
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1" ]
interval: 5s
timeout: 2s
retries: 10
interval: 3s
timeout: 1s
retries: 20
2 changes: 0 additions & 2 deletions docker-compose/common/compose-include/alloy.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
services:
alloy:
labels:
logs.grafana.com/log-format: logfmt
depends_on: { gateway: { condition: service_healthy } }
image: ${ALLOY_IMAGE:-docker.io/grafana/alloy:v1.0.0}
configs:
Expand Down
1 change: 0 additions & 1 deletion docker-compose/common/compose-include/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ services:
grafana:
labels:
metrics.grafana.com/scrape: false
logs.grafana.com/log-format: logfmt
image: ${GRAFANA_IMAGE:-docker.io/grafana/grafana:10.4.1}
command:
- --config=/etc/grafana-config/grafana.ini
Expand Down
7 changes: 3 additions & 4 deletions docker-compose/common/compose-include/loki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ services:
loki:
labels:
metrics.grafana.com/scrape: false
logs.grafana.com/log-format: json
depends_on: { minio: { condition: service_healthy } }
image: ${LOKI_IMAGE:-docker.io/grafana/loki:3.0.0}
volumes:
Expand All @@ -13,9 +12,9 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 3s
timeout: 2s
retries: 10
interval: 2s
timeout: 1s
retries: 15
# expose 33100 port so we can directly access loki inside container
ports:
- "33100:3100"
Expand Down
8 changes: 5 additions & 3 deletions docker-compose/common/compose-include/mimir.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

services:
mimir:
labels:
metrics.grafana.com/scrape: false
depends_on: { minio: { condition: service_healthy } }
image: ${MIMIR_IMAGE:-docker.io/grafana/mimir:2.12.0}
volumes:
Expand All @@ -11,9 +13,9 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/ready || exit 1" ]
interval: 3s
timeout: 2s
retries: 10
interval: 2s
timeout: 1s
retries: 15
# expose 38080 port so we can directly access mimir inside container
ports:
- "38080:8080"
Expand Down
6 changes: 3 additions & 3 deletions docker-compose/common/compose-include/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ services:
- minio_data:/data:delegated
healthcheck:
test: ["CMD-SHELL", "mc ready local"]
interval: 3s
timeout: 2s
retries: 10
interval: 2s
timeout: 1s
retries: 15
ports:
- "9001:9001"

Expand Down
7 changes: 3 additions & 4 deletions docker-compose/common/compose-include/pyroscope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
metrics.grafana.com/scrape: false
depends_on: { minio: { condition: service_healthy } }
image: ${PYROSCOPE_IMAGE:-docker.io/grafana/pyroscope:1.5.0}
container_name: pyroscope
volumes:
- ../config/pyroscope:/etc/pyroscope
- pyroscope_data:/data
Expand All @@ -15,9 +14,9 @@ services:
# - -runtime-config.file=/etc/pyroscope/overrides.yaml
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:4040/ready || exit 1" ]
interval: 3s
timeout: 2s
retries: 10
interval: 2s
timeout: 1s
retries: 15
# expose 34040 port so we can directly access pyroscope inside container
ports:
- "34040:4040"
Expand Down
8 changes: 4 additions & 4 deletions docker-compose/common/compose-include/tempo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ services:
- -config.expand-env=true
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3200/ready || exit 1" ]
interval: 3s
timeout: 2s
retries: 10
start_period: 10s
interval: 2s
timeout: 1s
retries: 15
# start_period: 10s
# expose 33200 port so we can directly access tempo inside container
ports:
- "33200:3200"
15 changes: 9 additions & 6 deletions docker-compose/common/config/alloy/all-in-one.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import.file "provider" {

// get self hosted receivers provider
provider.self_hosted "compose" {
logs_endpoint = "http://gateway:3100"
metrics_endpoint = "http://gateway:8080"
traces_endpoint = "http://gateway:4318"
profiles_endpoint = "http://gateway:4040"
logs_endpoint_url = "http://gateway:3100/loki/api/v1/push"
metrics_endpoint_url = "http://gateway:8080/api/v1/push"
traces_endpoint_url = "http://gateway:4318"
profiles_endpoint_url = "http://gateway:4040"
}

/********************************************
Expand Down Expand Up @@ -73,8 +73,11 @@ traces.pat "all" {
}

tracing {
sampling_fraction = 0.8
write_to = [traces.pat.all.alloy_traces_input]
// Write all spans. Don't do this in production!
sampling_fraction = 1

// Forward Alloy internal spans to traces process.
write_to = [traces.pat.all.alloy_traces_input]
}

/********************************************
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/common/config/alloy/logs.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import.file "provider" {

// get lgtmp receivers provider
provider.self_hosted "compose" {
logs_endpoint = "http://gateway:3100"
metrics_endpoint = "http://gateway:8080"
logs_endpoint_url = "http://gateway:3100/loki/api/v1/push"
metrics_endpoint_url = "http://gateway:8080/api/v1/push"
}

/********************************************
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/common/config/alloy/metrics.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import.file "provider" {

// get lgtmp receivers provider
provider.self_hosted "compose" {
metrics_endpoint = "http://gateway:8080"
metrics_endpoint_url = "http://gateway:8080/api/v1/push"
}

/********************************************
Expand Down
6 changes: 3 additions & 3 deletions docker-compose/common/config/alloy/modules/compose/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker Compose `labels` Auto-Scraping Modules
# Docker Compose `labels_scrape` Components

## Logs

Expand All @@ -22,7 +22,7 @@ The following service labels are supported for gathering of metrics for docker c
| `metrics.grafana.com/path` <br>or<br> `prometheus.io/path` | the default path to scrape is `/metrics`, this can be specified as a single value which would override, the scrape path being used for all ports attached to the target |
| `metrics.grafana.com/port` <br>or<br> `prometheus.io/port` | the default `port` to scrape is the target port, this can be specified as a single value which would override the scrape port being used for all ports attached to the target, note that even if an target had multiple targets, the relabel_config targets are deduped before scraping |
| `metrics.grafana.com/tenant` | The tenant their metrics should be sent to, this does not necessarily have to be the actual tenantId, it can be a friendly name as well that is simply used to determine if the metrics should be gathered for the current tenant |
| `metrics.grafana.com/job` <br>or<br> `prometheus.io/job` | The job label value to use when collecting their metrics. However, it is common to use an integration or community project where rules / dashboards are provided for you. Oftentimes, this provided assets use hard-coded values for a job label i.e. `...{job="integrations/kubernetes/cadvisor"...}` or `...{job="minio-job"...}` setting this annotation to that value will allow the provided asset to work out of the box. |
| `metrics.grafana.com/job` <br>or<br> `prometheus.io/job` | The job label value to use when collecting their metrics. However, it is common to use an integration or community project where rules / dashboards are provided for you. Oftentimes, this provided assets use hard-coded values for a job label i.e. `...{job="integrations/cadvisor"...}` or `...{job="minio-job"...}` setting this annotation to that value will allow the provided asset to work out of the box. |
| `metrics.grafana.com/interval` <br>or<br> `prometheus.io/interval` | The default interval to scrape is `15s`, this can be override. |
| `metrics.grafana.com/timeout` <br>or<br> `prometheus.io/timeout` | The default timeout for scraping is `10s`, this can be override. |

Expand All @@ -32,7 +32,7 @@ The following service labels are supported for gathering of metrics for docker c

The following service labels are supported for docker compose services:

> The full list of profile types supported by labels is `cpu`, `memory`, `goroutine`, `block`, `mutex` and `fgprof`:
> The full list of <profile-type> supported by labels is `cpu`, `memory`, `goroutine`, `block`, `mutex` and `fgprof`:
| Label | Description |
| :--------------- | :-----------|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Module(logs_auto_scrape): Docker Containers Logs Auto-Scraping
Component: labels_scrape
Description: Scrapes targets for logs based on Docker Containers labels

Following labels are available:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Module(metrics): Docker Containers Auto-Scraping
Component: labels_scrape
Description: Scrapes targets for metrics based on Docker Containers labels

Note: Every argument except for "forward_to" is optional, and does have a defined default value. However, the values for these
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Module(profiles_auto_scrape): Docker Containers Auto-Scraping
Component: labels_scrape
Description: Scrapes targets for profiles based on Docker Containers labels

The full list of profile types supported by labels is "cpu", "memory", "goroutine", "block", "mutex" and "fgprof"
Expand Down
32 changes: 16 additions & 16 deletions docker-compose/common/config/alloy/modules/provider/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Receivers Provider Moudle
# Data receiver provider components

Provide the receivers of the collected data(`logs` `metrics` `traces` `profiles`).

Expand All @@ -13,21 +13,21 @@ Module to configure receivers for Self Hosted LGTMP Stack.

***Arguments***

| Name | Required | Default | Description |
| :------------------ | :------- | :---------------------- | :--------------------------------- |
| `metrics_endpoint` | _no_ | `http://mimir:8080` | Where to send collected `metrics`. |
| `logs_endpoint` | _no_ | `http://loki:3100` | Where to send collected `logs`. |
| `traces_endpoint` | _no_ | `tempo:4317` | Where to send collected `traces`. |
| `profiles_endpoint` | _no_ | `http://pyroscope:4040` | Where to send collected `profiles`.|
| Name | Required | Default | Description |
| :---------------------- | :------- | :-------------------------------------- | :--------------------------------- |
| `metrics_endpoint_url` | _no_ | `http://mimir:8080/api/v1/push` | Where to send collected `metrics`. |
| `logs_endpoint_url` | _no_ | `http://loki:3100/loki/api/v1/push` | Where to send collected `logs`. |
| `traces_endpoint_url` | _no_ | `http://tempo:4318` | Where to send collected `traces`. |
| `profiles_endpoint_url` | _no_ | `http://pyroscope:4040` | Where to send collected `profiles`.|

***Exports***

| Name | Type | Description |
| --------------------| ------------------------ | --------------------------------------------------------------------------- |
| `metrics_receiver` | `prometheus.Interceptor` | A value that other components can use to send metrics data to. |
| `logs_receiver` | `loki.LogsReceiver` | A value that other components can use to send logs data to. |
| `traces_receiver` | `otelcol.Consumer` | A value that other components can use to send trace data to. |
| `profiles_receiver` | `write.fanOutClient` | A value that other components can use to send profiling data to. |
| Name | Type | Description |
| --------------------| ------------------------ | ---------------------------------------------------------------- |
| `metrics_receiver` | `prometheus.Interceptor` | A value that other components can use to send metrics data to. |
| `logs_receiver` | `loki.LogsReceiver` | A value that other components can use to send logs data to. |
| `traces_receiver` | `otelcol.Consumer` | A value that other components can use to send trace data to. |
| `profiles_receiver` | `write.fanOutClient` | A value that other components can use to send profiling data to. |

***Example***

Expand All @@ -41,12 +41,12 @@ import.git "provider" {
// get the receivers from provider
provider.self_hosted "compose" {
metrics_endpoint = "http://mimir:8080"
metrics_endpoint_url = "http://mimir:8080/api/v1/push"
}
// get the receivers from provider
provider.self_hosted "kubernetes" {
metrics_endpoint = "http://mimir.monitoring-system.svc.cluster.local:8080"
metrics_endpoint_url = "http://mimir.monitoring-system.svc.cluster.local:8080/api/v1/push"
}
// scrape metrics and write to metric receiver
Expand Down Expand Up @@ -107,7 +107,7 @@ import.git "provider" {
// get the receivers from provider
provider.grafana_cloud "stack_name" {
stack_name = env("GRAFANA_CLOUD_STACK_NAME")
token = env("GRAFANA_CLOUD_STACK_TOKEN")
token = env("GRAFANA_CLOUD_TOKEN")
}
// scrape metrics and write to metric receiver
Expand Down
Loading

0 comments on commit 05fa37c

Please sign in to comment.