-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from qclaogui:docker-desktop-mixin
Add Docker Desktop Mixin
- Loading branch information
Showing
20 changed files
with
4,382 additions
and
59 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,101 @@ | ||
/* | ||
Module Components: component_alloy | ||
*/ | ||
|
||
declare "component_alloy" { | ||
|
||
/***************************************************************** | ||
* ARGUMENTS | ||
*****************************************************************/ | ||
argument "forward_to" { | ||
comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" | ||
} | ||
|
||
argument "job_label" { | ||
optional = true | ||
default = "integrations/alloy-check" | ||
} | ||
|
||
argument "instance_name" { | ||
optional = true | ||
} | ||
|
||
argument "keep_metrics" { | ||
optional = true | ||
default = "(prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|alloy_build.*|prometheus_remote_write_wal_samples_appended_total|process_start_time_seconds)" | ||
} | ||
|
||
argument "scrape_interval" { | ||
comment = "How often to scrape metrics from the targets (default: 60s)" | ||
optional = true | ||
default = "60s" | ||
} | ||
|
||
argument "scrape_timeout" { | ||
comment = "How long before a scrape times out (default: 10s)" | ||
optional = true | ||
default = "10s" | ||
} | ||
|
||
/*************************************************************** | ||
* Integrations cAdvisor | ||
****************************************************************/ | ||
prometheus.exporter.self "integrations_alloy" { } | ||
|
||
/*************************************************************** | ||
* Discovery Relabelings (pre-scrape) | ||
****************************************************************/ | ||
discovery.relabel "integrations_alloy" { | ||
targets = prometheus.exporter.unix.integrations_alloy.targets | ||
|
||
rule { | ||
target_label = "job" | ||
replacement = argument.job_label.value | ||
} | ||
|
||
rule { | ||
target_label = "instance" | ||
replacement = coalesce(argument.instance_name.value, constants.hostname) | ||
} | ||
|
||
rule { | ||
target_label = "alloy_hostname" | ||
replacement = constants.hostname | ||
} | ||
} | ||
|
||
/*************************************************************** | ||
* Prometheus Scrape Integrations Targets | ||
****************************************************************/ | ||
prometheus.scrape "integrations_alloy" { | ||
targets = concat( | ||
discovery.relabel.integrations_alloy.output, | ||
) | ||
|
||
enable_protobuf_negotiation = true | ||
scrape_classic_histograms = true | ||
|
||
scrape_interval = argument.scrape_interval.value | ||
scrape_timeout = argument.scrape_timeout.value | ||
|
||
clustering { | ||
enabled = true | ||
} | ||
|
||
forward_to = [prometheus.relabel.integrations_alloy.receiver] | ||
} | ||
|
||
/*************************************************************** | ||
* Prometheus Metric Relabelings (post-scrape) | ||
****************************************************************/ | ||
prometheus.relabel "integrations_alloy" { | ||
forward_to = argument.forward_to.value | ||
|
||
// keep only metrics that match the keep_metrics regex | ||
rule { | ||
source_labels = ["__name__"] | ||
regex = argument.keep_metrics.value | ||
action = "keep" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ declare "keep_labels" { | |
"cluster", | ||
"namespace", | ||
"pod", | ||
"instance", | ||
"container", | ||
"component", | ||
"env", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
include ../../.bingo/Variables.mk | ||
|
||
# path to jsonnetfmt | ||
JSONNET_FMT := $(JSONNETFMT) -n 2 --max-blank-lines 2 --string-style s --comment-style s | ||
# path to the mixin | ||
MIXIN_OUT_PATH := deploy | ||
|
||
CURRENT_DIR = $(notdir $(shell pwd)) | ||
|
||
.PHONY: fmt | ||
fmt: ## Format the mixin files | ||
@find . -type f -name '*.libsonnet' | xargs -n 1 -- $(JSONNET_FMT) -i | ||
|
||
.PHONY: update | ||
update: $(JB) ## update mixin | ||
$(JB) update | ||
|
||
define build_mixin_func | ||
$(eval $@_MIXIN_OUTPUT = $(1)) | ||
@mkdir -p "${$@_MIXIN_OUTPUT}"; \ | ||
find "${$@_MIXIN_OUTPUT}" ! -name "kustomization.yaml" ! -name "prometheus-alerts.yaml" ! -name "prometheus-rules.yaml" -type f -delete | ||
@$(MIXTOOL) generate all --output-alerts "${$@_MIXIN_OUTPUT}/alerts.yaml" --output-rules "${$@_MIXIN_OUTPUT}/rules.yaml" --directory "${$@_MIXIN_OUTPUT}/dashboards_out" "${$@_MIXIN_OUTPUT}.libsonnet" | ||
@mv ${$@_MIXIN_OUTPUT}/alerts.yaml ${$@_MIXIN_OUTPUT}/${CURRENT_DIR}-alerts.yaml | ||
@mv ${$@_MIXIN_OUTPUT}/rules.yaml ${$@_MIXIN_OUTPUT}/${CURRENT_DIR}-rules.yaml | ||
endef | ||
|
||
|
||
.PHONY: build | ||
build: $(MIXTOOL) ## Generates the mixin files | ||
$(foreach mixin,$(MIXIN_OUT_PATH),$(call build_mixin_func, $(mixin))) | ||
|
||
.PHONY: check | ||
check: $(MIXTOOL) build fmt ## Build, fmt and check the mixin files | ||
@../../tools/find-diff-or-untracked.sh . "$(MIXIN_OUT_PATH)" || (echo "Please build and fmt mixin by running 'make build fmt'" && false); \ | ||
# jb install && \ | ||
# $(MIXTOOL) lint mixin.libsonnet | ||
|
||
##@ Dashboards & k8s | ||
|
||
.PHONY: manifests | ||
manifests: $(KUSTOMIZE) build ## Generates dashboards for k8s | ||
$(KUSTOMIZE) build deploy > deploy/manifests/k8s-all-in-one.yaml | ||
|
||
# NOTE: dashboards_out has been deprecated, please use build instead | ||
dashboards_out: | ||
@mkdir -p deploy/dashboards_out deploy/manifests | ||
jsonnet -J vendor -e '(import "mixin.libsonnet").grafanaDashboards' -m deploy/dashboards_out | ||
|
||
prom_alerts.yaml: | ||
jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusAlerts)' > deploy/$@ | ||
|
||
prom_rules.yaml: | ||
jsonnet -J vendor -S -e 'std.manifestYamlDoc((import "mixin.libsonnet").prometheusRules)' > deploy/$@ | ||
|
||
##@ General | ||
|
||
.PHONY: help | ||
help: ## Display this help. Thanks to https://www.thapaliya.com/en/writings/well-documented-makefiles/ | ||
ifeq ($(OS),Windows_NT) | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n"} /^[a-zA-Z_-]+:.*?##/ { printf " %-40s %s\n", $$1, $$2 } /^##@/ { printf "\n%s\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
else | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
endif |
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,10 @@ | ||
(import 'mixin.libsonnet') + { | ||
// Config overrides | ||
_config+:: { | ||
dashboardTags: ['docker'], | ||
dashboardPeriod: 'now-1h', | ||
dashboardTimezone: 'default', | ||
dashboardRefresh: '1m', | ||
enableLokiLogs: true, | ||
}, | ||
} |
Oops, something went wrong.