Skip to content

Commit 7999314

Browse files
authored
Merge pull request #7182 from sbueringer/pr-bump-loki-chart
🌱 hack/observability: Bump Loki, Grafana and promtail charts
2 parents 94ca9a7 + 8f91bc6 commit 7999314

File tree

10 files changed

+72
-20
lines changed

10 files changed

+72
-20
lines changed

Tiltfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ def deploy_provider_crds():
403403
def deploy_observability():
404404
if "promtail" in settings.get("deploy_observability", []):
405405
k8s_yaml(read_file("./.tiltbuild/yaml/promtail.observability.yaml"), allow_duplicates = True)
406-
k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"], resource_deps = ["loki"])
406+
k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"], resource_deps = ["loki"], objects = ["promtail:serviceaccount"])
407407

408408
if "loki" in settings.get("deploy_observability", []):
409409
k8s_yaml(read_file("./.tiltbuild/yaml/loki.observability.yaml"), allow_duplicates = True)
410-
k8s_resource(workload = "loki", port_forwards = "3100", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"])
410+
k8s_resource(workload = "loki", port_forwards = "3100", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"], objects = ["loki:serviceaccount"])
411411

412412
cmd_button(
413413
"loki:import logs",
@@ -426,11 +426,11 @@ def deploy_observability():
426426

427427
if "prometheus" in settings.get("deploy_observability", []):
428428
k8s_yaml(read_file("./.tiltbuild/yaml/prometheus.observability.yaml"), allow_duplicates = True)
429-
k8s_resource(workload = "prometheus-server", new_name = "prometheus", port_forwards = "9090", extra_pod_selectors = [{"app": "prometheus"}], labels = ["observability"])
429+
k8s_resource(workload = "prometheus-server", new_name = "prometheus", port_forwards = "9090", extra_pod_selectors = [{"app": "prometheus"}], labels = ["observability"], objects = ["prometheus-server:serviceaccount"])
430430

431431
if "kube-state-metrics" in settings.get("deploy_observability", []):
432432
k8s_yaml(read_file("./.tiltbuild/yaml/kube-state-metrics.observability.yaml"), allow_duplicates = True)
433-
k8s_resource(workload = "kube-state-metrics", new_name = "kube-state-metrics", extra_pod_selectors = [{"app": "kube-state-metrics"}], labels = ["observability"])
433+
k8s_resource(workload = "kube-state-metrics", new_name = "kube-state-metrics", extra_pod_selectors = [{"app": "kube-state-metrics"}], labels = ["observability"], objects = ["kube-state-metrics:serviceaccount"])
434434

435435
if "visualizer" in settings.get("deploy_observability", []):
436436
k8s_yaml(read_file("./.tiltbuild/yaml/visualizer.observability.yaml"), allow_duplicates = True)
@@ -439,6 +439,7 @@ def deploy_observability():
439439
new_name = "visualizer",
440440
port_forwards = [port_forward(local_port = 8000, container_port = 8081, name = "View visualization")],
441441
labels = ["observability"],
442+
objects = ["capi-visualizer:serviceaccount"],
442443
)
443444

444445
def prepare_all():

docs/book/src/developer/providers/migrations/v1.4-to-v1.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ maintainers of providers and consumers of our Go API.
3535

3636
### Suggested changes for providers
3737

38-
-
38+
-

hack/observability/grafana/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ helmCharts:
77
releaseName: grafana
88
namespace: observability
99
valuesFile: values.yaml
10-
version: 6.35.0
10+
version: 6.56.5

hack/observability/grafana/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ datasources:
2222
- name: Loki
2323
type: loki
2424
url: http://loki:3100
25+
# This header has to be set as we had to set an OrgID
26+
# in promtail to be able to push the logs to Loki.
27+
jsonData:
28+
httpHeaderName1: 'X-Scope-OrgID'
29+
secureJsonData:
30+
httpHeaderValue1: '1'
2531
- name: Prometheus
2632
type: prometheus
2733
url: http://prometheus-server

hack/observability/loki/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ helmCharts:
77
releaseName: loki
88
namespace: observability
99
valuesFile: values.yaml
10-
version: 2.16.0
10+
version: 5.5.2

hack/observability/loki/values.yaml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
# Placeholder for loki chart configuration, see https://github.com/grafana/helm-charts/tree/main/charts/loki
2-
3-
# Set high ingestion limits so log-push can push logs without hitting the rate limits:
4-
# Push response: status: "429 Too Many Requests", body: "Ingestion rate limit exceeded for user fake (limit:
5-
# 4194304 bytes/sec) while attempting to ingest '1000' lines totaling '755293' bytes, reduce log volume or
6-
# contact your Loki administrator to see if the limit can be increased"
7-
config:
2+
# This configuration is necessary to deploy Loki in the
3+
# "Single Binary" mode.
4+
loki:
5+
commonConfig:
6+
replication_factor: 1
7+
storage:
8+
type: 'filesystem'
9+
rulerConfig:
10+
storage:
11+
type: local
12+
# Set high ingestion limits so log-push can push logs without hitting the rate limits:
13+
# Push response: status: "429 Too Many Requests", body: "Ingestion rate limit exceeded for user fake (limit:
14+
# 4194304 bytes/sec) while attempting to ingest '1000' lines totaling '755293' bytes, reduce log volume or
15+
# contact your Loki administrator to see if the limit can be increased"
816
limits_config:
917
ingestion_rate_mb: 1024
1018
ingestion_burst_size_mb: 1024
19+
singleBinary:
20+
replicas: 1
21+
22+
# We are disabling basically everything because we just want
23+
# Loki and no additional monitoring.
24+
monitoring:
25+
dashboards:
26+
# -- If enabled, create configmap with dashboards for monitoring Loki
27+
enabled: false
28+
rules:
29+
# -- If enabled, create PrometheusRule resource with Loki recording rules
30+
enabled: false
31+
alerts:
32+
# -- If enabled, create PrometheusRule resource with Loki alerting rules
33+
enabled: false
34+
serviceMonitor:
35+
# -- If enabled, ServiceMonitor resources for Prometheus Operator are created
36+
enabled: false
37+
selfMonitoring:
38+
enabled: false
39+
grafanaAgent:
40+
installOperator: false
41+
lokiCanary:
42+
enabled: false
43+
44+
test:
45+
enabled: false

hack/observability/promtail/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ helmCharts:
77
releaseName: promtail
88
namespace: observability
99
valuesFile: values.yaml
10-
version: 6.3.0
10+
version: 6.11.2

hack/observability/promtail/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ config:
44
# publish data to loki
55
clients:
66
- url: http://loki:3100/loki/api/v1/push
7+
# We have to set the tenant_id/OrgID to push logs to Loki
8+
# otherwise we get an auth error.
9+
tenant_id: 1
710

811
snippets:
912
pipelineStages:

hack/tools/log-push/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var (
5252
logFileRegex = flag.String("log-file-regex", "manager\\.log", "Regex used to find log files")
5353
logJSONAdditionalLabels = flag.String("log-json-additional-labels", "controller,cluster,machine", "Comma-separated list of additional labels to parse from JSON logs")
5454
lokiURL = flag.String("loki-url", "http://localhost:3100/loki/api/v1/push", "Loki URL to push the logs to")
55+
lokiOrgID = flag.String("loki-org-id", "1", "Loki Org ID used when pushing logs")
5556
)
5657

5758
func main() {
@@ -67,15 +68,15 @@ func main() {
6768
}
6869
logJSONAdditionalLabelsArray := strings.Split(*logJSONAdditionalLabels, ",")
6970

70-
if err := importLogs(*logPath, logFileRegexp, logJSONAdditionalLabelsArray, *lokiURL); err != nil {
71+
if err := importLogs(*logPath, logFileRegexp, logJSONAdditionalLabelsArray, *lokiURL, *lokiOrgID); err != nil {
7172
fmt.Printf("Failed to import logs: %v\n", err)
7273
os.Exit(1)
7374
}
7475

7576
klog.Infof("Finished syncing logs from %s", *logPath)
7677
}
7778

78-
func importLogs(logPath string, logFileRegex *regexp.Regexp, logJSONAdditionalLabels []string, lokiURL string) error {
79+
func importLogs(logPath string, logFileRegex *regexp.Regexp, logJSONAdditionalLabels []string, lokiURL, lokiOrgID string) error {
7980
ctx := context.Background()
8081

8182
// Get Logs.
@@ -92,7 +93,7 @@ func importLogs(logPath string, logFileRegex *regexp.Regexp, logJSONAdditionalLa
9293
}
9394

9495
// Push logs to Loki.
95-
if err := pushLogsToLoki(ctx, lokiURL, logFile, streams); err != nil {
96+
if err := pushLogsToLoki(ctx, lokiURL, lokiOrgID, logFile, streams); err != nil {
9697
return errors.Wrapf(err, "failed to push logs to Loki")
9798
}
9899
}
@@ -378,7 +379,7 @@ func prepareLogsForLoki(ld LogData, logJSONAdditionalLabels []string) ([]LokiStr
378379
}
379380

380381
// pushLogsToLoki uploads data to Loki.
381-
func pushLogsToLoki(ctx context.Context, lokiURL, file string, lokiLogStreamsArray []LokiStreams) error {
382+
func pushLogsToLoki(ctx context.Context, lokiURL, lokiOrgID, file string, lokiLogStreamsArray []LokiStreams) error {
382383
klog.Infof("Pushing logs to Loki from: %s", file)
383384

384385
for _, streams := range lokiLogStreamsArray {
@@ -388,15 +389,15 @@ func pushLogsToLoki(ctx context.Context, lokiURL, file string, lokiLogStreamsArr
388389
return errors.Wrapf(err, "failed to marshal Loki stream")
389390
}
390391

391-
if err := pushStreamToLoki(ctx, lokiURL, body); err != nil {
392+
if err := pushStreamToLoki(ctx, lokiURL, lokiOrgID, body); err != nil {
392393
return errors.Wrapf(err, "failed to push Loki stream")
393394
}
394395
}
395396

396397
return nil
397398
}
398399

399-
func pushStreamToLoki(ctx context.Context, lokiURL string, body []byte) error {
400+
func pushStreamToLoki(ctx context.Context, lokiURL, lokiOrgID string, body []byte) error {
400401
// gzip JSON into buf.
401402
var buf bytes.Buffer
402403
gz := gzip.NewWriter(&buf)
@@ -414,6 +415,7 @@ func pushStreamToLoki(ctx context.Context, lokiURL string, body []byte) error {
414415
}
415416
req.Header.Set("Content-Type", "application/json")
416417
req.Header.Set("Content-Encoding", "gzip")
418+
req.Header.Set("X-Scope-OrgID", lokiOrgID)
417419

418420
resp, err := http.DefaultClient.Do(req)
419421
if err != nil {

hack/tools/tilt-prepare/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import (
5555
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
5656
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
5757
"sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
58+
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
5859
"sigs.k8s.io/cluster-api/test/infrastructure/container"
5960
utilyaml "sigs.k8s.io/cluster-api/util/yaml"
6061
)
@@ -149,6 +150,10 @@ func init() {
149150
// This tool aims to speed up tilt startup time by running in parallel a set of task
150151
// preparing everything is required for tilt up.
151152
func main() {
153+
// Set clusterctl logger with a log level of 5.
154+
// This makes it easier to see what clusterctl is doing and to debug it.
155+
logf.SetLogger(logf.NewLogger(logf.WithThreshold(pointer.Int(5))))
156+
152157
klog.Infof("[main] started\n")
153158
start := time.Now()
154159

0 commit comments

Comments
 (0)