-
Notifications
You must be signed in to change notification settings - Fork 489
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
Introduce experimental cluster-aware metrics subsystem #1261
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a7ab216
add top-level cluster subsystem
rfratto 1661420
add metrics-next experimental feature
rfratto 3bc257e
working example (potentially) (maybe)
rfratto 6874b66
metrics/v2: start on an API
rfratto 9541c7e
modify discovery jobs API to include node name
rfratto c0d8704
metrics/v2: make discovery targets API node-aware
rfratto 1c870e5
metrics/v2: add API for current scrape targets
rfratto 119b4c2
add metrics for discoverer, scraper, sender
rfratto 460a2a2
pkg/cluster: fix bug where escaped discovery strings were getting une…
rfratto cd5e285
pkg/cluster: appendDefaultPort incorrect
rfratto 66745d5
example/k3d: create metrics-next example environment
rfratto 38a1586
metrics/v2: fix metrics metadata
rfratto 6179dfa
fix compile errors after rebase, lint errors
rfratto 2e5297c
use rfratto/ckit/advertise to find advertise IP
rfratto 7da7a52
use ckit/httpgrpc
rfratto 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 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
/.vscode | ||
vendor | ||
|
||
agent-data | ||
/cmd/agent/agent | ||
/cmd/agentctl/agentctl | ||
/cmd/agent-operator/agent-operator | ||
|
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,26 @@ | ||
server: | ||
log_level: debug | ||
|
||
metrics: | ||
global: | ||
scrape_interval: 1m | ||
configs: | ||
- name: default | ||
scrape_configs: | ||
- job_name: demo.robustperception.io | ||
static_configs: | ||
- targets: ['demo.robustperception.io:3000'] | ||
labels: | ||
app: grafana | ||
- targets: ['demo.robustperception.io:9090'] | ||
labels: | ||
app: prometheus | ||
- targets: ['demo.robustperception.io:9100'] | ||
labels: | ||
app: node_exporter | ||
- targets: ['demo.robustperception.io:9093'] | ||
labels: | ||
app: alertmanager | ||
- targets: ['demo.robustperception.io:9091'] | ||
labels: | ||
app: pushgateway | ||
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,99 @@ | ||
local default = import 'default/main.libsonnet'; | ||
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. Maybe any kind of k3d code should be moved to another PR and defer to docker-compose for the initial PR? |
||
local gragent = import 'grafana-agent/v2/main.libsonnet'; | ||
local k = import 'ksonnet-util/kausal.libsonnet'; | ||
|
||
local ingress = k.networking.v1beta1.ingress; | ||
local pvc = k.core.v1.persistentVolumeClaim; | ||
local path = k.networking.v1beta1.httpIngressPath; | ||
local rule = k.networking.v1beta1.ingressRule; | ||
local container = k.core.v1.container; | ||
local volumeMount = k.core.v1.volumeMount; | ||
|
||
local images = { | ||
agent: 'grafana/agent:latest', | ||
agentctl: 'grafana/agentctl:latest', | ||
}; | ||
|
||
{ | ||
default: default.new(namespace='default') { | ||
grafana+: { | ||
ingress+: | ||
ingress.new('grafana-ingress') + | ||
ingress.mixin.spec.withRules([ | ||
rule.withHost('grafana.k3d.localhost') + | ||
rule.http.withPaths([ | ||
path.withPath('/') | ||
+ path.backend.withServiceName('grafana') | ||
+ path.backend.withServicePort(80), | ||
]), | ||
]), | ||
}, | ||
}, | ||
|
||
logging_agents: | ||
gragent.new(name='grafana-agent-logs', namespace='default') + | ||
gragent.withImagesMixin(images) + | ||
gragent.withDaemonSetController() + | ||
gragent.withLogVolumeMounts() + | ||
gragent.withLogPermissions() + | ||
gragent.withAgentConfig({ | ||
server: { log_level: 'debug' }, | ||
|
||
logs: { | ||
positions_directory: '/tmp/loki-positions', | ||
configs: [{ | ||
name: 'default', | ||
clients: [{ | ||
url: 'http://loki.default.svc.cluster.local/loki/api/v1/push', | ||
external_labels: { cluster: 'k3d' }, | ||
}], | ||
scrape_configs: [ | ||
x { pipeline_stages: [{ cri: {} }] } | ||
for x | ||
in gragent.newKubernetesLogs() | ||
], | ||
}], | ||
}, | ||
}), | ||
|
||
|
||
agent_cluster: | ||
gragent.new(name='grafana-agent', namespace='default') { | ||
container+:: container.withArgsMixin(k.util.mapToFlags({ | ||
'cluster.enable': 'true', | ||
'cluster.discover-peers': 'provider=k8s namespace=default label_selector="name=grafana-agent"', | ||
|
||
'enable-features': 'metrics-next', | ||
'metrics.wal.directory': '/var/lib/agent', | ||
})), | ||
} + | ||
gragent.withImagesMixin(images) + | ||
gragent.withStatefulSetController( | ||
replicas=3, | ||
volumeClaims=[ | ||
pvc.new() + | ||
pvc.mixin.metadata.withName('agent-wal') + | ||
pvc.mixin.metadata.withNamespace('smoke') + | ||
pvc.mixin.spec.withAccessModes('ReadWriteOnce') + | ||
pvc.mixin.spec.resources.withRequests({ storage: '5Gi' }), | ||
], | ||
) + | ||
gragent.withVolumeMountsMixin([volumeMount.new('agent-wal', '/var/lib/agent')]) + | ||
gragent.withAgentConfig({ | ||
server: { log_level: 'debug' }, | ||
|
||
metrics: { | ||
global: { | ||
scrape_interval: '15s', | ||
external_labels: { cluster: 'k3d' }, | ||
}, | ||
configs: [{ | ||
name: 'default', | ||
scrape_configs: gragent.newKubernetesMetrics({}), | ||
remote_write: [{ | ||
url: 'http://cortex.default.svc.cluster.local/api/prom/push', | ||
}], | ||
}], | ||
}, | ||
}), | ||
} |
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,11 @@ | ||
{ | ||
"apiVersion": "tanka.dev/v1alpha1", | ||
"kind": "Environment", | ||
"metadata": { | ||
"name": "default" | ||
}, | ||
"spec": { | ||
"apiServer": "https://0.0.0.0:50443", | ||
"namespace": "default" | ||
} | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was used for quick testing but we probably shouldn't hammer the robustperception demo server by making it an official example config :)