Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
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
1 change: 1 addition & 0 deletions production/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For sample configurations and detailed installation instructions, please head to

- [Grafana Agent Metrics Kubernetes Quickstart](https://grafana.com/docs/grafana-cloud/quickstart/agent-k8s/k8s_agent_metrics/)
- [Grafana Agent Logs Kubernetes Quickstart](https://grafana.com/docs/grafana-cloud/quickstart/agent-k8s/k8s_agent_logs/)
- [Grafana Agent Traces Kubernetes Quickstart](https://grafana.com/docs/grafana-cloud/quickstart/agent-k8s/k8s_agent_traces/)

## Manually Applying

Expand Down
5 changes: 5 additions & 0 deletions production/kubernetes/agent-bare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
- -config.file=/etc/agent/agent.yaml
command:
- /bin/agent
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: grafana/agent:v0.16.1
imagePullPolicy: IfNotPresent
name: agent
Expand Down
4 changes: 4 additions & 0 deletions production/kubernetes/agent-loki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ spec:
command:
- /bin/agent
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: HOSTNAME
valueFrom:
fieldRef:
Expand Down
79 changes: 7 additions & 72 deletions production/kubernetes/agent-tempo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana-agent-traces
namespace: ${NAMESPACE}
---
apiVersion: v1
data:
agent.yaml: |
server:
http_listen_port: 8080
log_level: info
tempo:
configs:
- batch:
send_batch_size: 1000
timeout: 5s
name: default
receivers:
jaeger:
protocols:
grpc: null
thrift_binary: null
thrift_compact: null
thrift_http: null
remote_sampling:
insecure: true
strategy_file: /etc/agent/strategies.json
opencensus: null
otlp:
protocols:
grpc: null
http: null
zipkin: null
remote_write:
- basic_auth:
password: ${TEMPO_PASSWORD}
username: ${TEMPO_USERNAME}
endpoint: ${TEMPO_ENDPOINT}
retry_on_failure:
enabled: false
scrape_configs:
- bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: replace
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: false
strategies.json: '{"default_strategy": {"param": 0.001, "type": "probabilistic"}}'
kind: ConfigMap
metadata:
name: grafana-agent-traces
namespace: ${NAMESPACE}
namespace: YOUR_NAMESPACE
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
Expand Down Expand Up @@ -99,15 +37,15 @@ roleRef:
subjects:
- kind: ServiceAccount
name: grafana-agent-traces
namespace: ${NAMESPACE}
namespace: YOUR_NAMESPACE
---
apiVersion: v1
kind: Service
metadata:
labels:
name: grafana-agent-traces
name: grafana-agent-traces
namespace: ${NAMESPACE}
namespace: YOUR_NAMESPACE
spec:
ports:
- name: agent-http-metrics
Expand Down Expand Up @@ -145,12 +83,14 @@ spec:
name: grafana-agent-traces
---
apiVersion: apps/v1
kind: DaemonSet
kind: Deployment
metadata:
name: grafana-agent-traces
namespace: ${NAMESPACE}
namespace: YOUR_NAMESPACE
spec:
minReadySeconds: 10
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
name: grafana-agent-traces
Expand Down Expand Up @@ -200,12 +140,7 @@ spec:
- mountPath: /etc/agent
name: grafana-agent-traces
serviceAccount: grafana-agent-traces
tolerations:
- effect: NoSchedule
operator: Exists
volumes:
- configMap:
name: grafana-agent-traces
name: grafana-agent-traces
updateStrategy:
type: RollingUpdate
9 changes: 7 additions & 2 deletions production/kubernetes/build/templates/tempo/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local newPort(name, portNumber, protocol='TCP') =

{
agent:
agent.new('grafana-agent-traces', '${NAMESPACE}') +
agent.newDeployment('grafana-agent-traces', 'YOUR_NAMESPACE') +
agent.withConfigHash(false) +
agent.withImages({
agent: (import 'version.libsonnet'),
Expand Down Expand Up @@ -74,5 +74,10 @@ local newPort(name, portNumber, protocol='TCP') =
param: 0.001,
},
}) +
agent.withTempoScrapeConfigs(agent.tempoScrapeKubernetes),
agent.withTempoScrapeConfigs(agent.tempoScrapeKubernetes) + {
agent+: {
// Remove this block to generate ConfigMap
config_map:: {},
},
},
}
5 changes: 4 additions & 1 deletion production/tanka/grafana-agent/v1/internal/agent.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ local serviceAccount = k.core.v1.serviceAccount;
container.withCommand('/bin/agent') +
container.withArgsMixin(k.util.mapToFlags({
'config.file': '/etc/agent/agent.yaml',
})),
})) +
container.withEnvMixin([
k.core.v1.envVar.fromFieldPath('HOSTNAME', 'spec.nodeName'),
]),

agent:
(
Expand Down
54 changes: 44 additions & 10 deletions production/tanka/grafana-agent/v1/lib/deployment.libsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
local agent = import '../internal/agent.libsonnet';
local k = import 'ksonnet-util/kausal.libsonnet';

local configMap = k.core.v1.configMap;
local service = k.core.v1.service;
local container = k.core.v1.container;

{
// newDeployment creates a new single-replicaed Deployment of the
Expand Down Expand Up @@ -26,25 +31,54 @@ local agent = import '../internal/agent.libsonnet';

local has_prometheus_config = std.objectHasAll(self, '_prometheus_config'),
local has_prometheus_instances = std.objectHasAll(self, '_prometheus_instances'),
local has_tempo_config = std.objectHasAll(self, '_tempo_config'),
local has_sampling_strategies = std.objectHasAll(self, '_tempo_sampling_strategies'),

config:: {
server: {
log_level: 'info',
http_listen_port: 8080,
},

prometheus:
if !has_prometheus_config then {}
else this._prometheus_config {
configs:
if has_prometheus_instances
then this._prometheus_instances
else [],
} + (
if has_prometheus_config
then {
prometheus:
this._prometheus_config {
configs:
if has_prometheus_instances
then this._prometheus_instances
else [],
},
}
else {}
) + (
if has_tempo_config then {
tempo: {
configs: [this._tempo_config {
name: 'default',
}],
},
},
}
else {}
),

agent:
agent.newAgent(name, namespace, self._images.agent, self.config, use_daemonset=false) +
agent.withConfigHash(self._config_hash),
agent.withConfigHash(self._config_hash) + {
// If sampling strategies were defined, we need to mount them as a JSON
// file.
config_map+:
if has_sampling_strategies
then configMap.withDataMixin({
'strategies.json': std.toString(this._tempo_sampling_strategies),
})
else {},
// If we're deploying for tracing, applications will want to write to
// a service for load balancing span delivery.
service:
if has_tempo_config
then k.util.serviceFor(self.agent) + service.mixin.metadata.withNamespace(namespace)
else {},
},
},
}