-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add metrics support for poller and scaler events (#143)
* Add metrics support for scaler and poller events Including required role for metrics writing to scaler and poller service accounts. In GKE, the OpenTelemetry collector is used to collect and forward metrics to the monitoring backend. In Cloud Functions, the code is configured to send metrics to Cloud Monitoring.
- Loading branch information
Showing
38 changed files
with
16,316 additions
and
7,886 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
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
49 changes: 49 additions & 0 deletions
49
kubernetes/decoupled/autoscaler-config/otel-collector.yaml.template
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,49 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: otel-config | ||
namespace: spanner-autoscaler | ||
data: | ||
config.yaml: | | ||
--- | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
endpoint: 0.0.0.0:4317 | ||
|
||
processors: | ||
resourcedetection: | ||
detectors: [gcp] | ||
timeout: 10s | ||
override: false | ||
|
||
batch: | ||
# batch metrics before sending to reduce API usage | ||
send_batch_max_size: 200 | ||
send_batch_size: 200 | ||
timeout: 10s | ||
|
||
memory_limiter: | ||
# drop metrics if memory usage gets too high | ||
check_interval: 10s | ||
limit_percentage: 65 | ||
spike_limit_percentage: 20 | ||
|
||
exporters: | ||
googlecloud: | ||
timeout: 45s | ||
# Enable the debug exporter, and add to exporters pipeline to see the metrics being delivered | ||
# debug: | ||
# verbosity: detailed | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
processors: [resourcedetection, batch, memory_limiter] | ||
exporters: [googlecloud] | ||
telemetry: | ||
logs: | ||
# Change log level from "info" to "debug" to view detailed logs | ||
level: "info" |
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
21 changes: 21 additions & 0 deletions
21
kubernetes/decoupled/autoscaler-pkg/otel-collector/Kptfile
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,21 @@ | ||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: otel-collector | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: Config for OpenTelemetry Collector component of Spanner autoscaler |
17 changes: 17 additions & 0 deletions
17
kubernetes/decoupled/autoscaler-pkg/otel-collector/README.md
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,17 @@ | ||
# Open Telemtry Collector | ||
|
||
## Description | ||
|
||
Config for [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) | ||
component of Spanner Autoscaler | ||
|
||
### View package content | ||
|
||
`kpt pkg tree otel-collector` | ||
[Details](https://kpt.dev/reference/cli/pkg/tree/) | ||
|
||
## Installation | ||
|
||
See [documentation][docs] for installation and configuration instructions. | ||
|
||
[docs]: ../../../../terraform/gke/README.md |
48 changes: 48 additions & 0 deletions
48
kubernetes/decoupled/autoscaler-pkg/otel-collector/otel-collector.yaml
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,48 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: otel-collector | ||
namespace: spanner-autoscaler # kpt-set: ${namespace} | ||
labels: | ||
app: otel-collector | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: otel-collector | ||
template: | ||
metadata: | ||
labels: | ||
app: otel-collector | ||
spec: | ||
containers: | ||
- name: otel-collector | ||
image: otel/opentelemetry-collector-contrib:0.93.0 | ||
args: | ||
- --config | ||
- /etc/otel/config.yaml | ||
volumeMounts: | ||
- mountPath: /etc/otel/ | ||
name: otel-config | ||
volumes: | ||
- name: otel-config | ||
configMap: | ||
name: otel-config | ||
nodeSelector: | ||
iam.gke.io/gke-metadata-server-enabled: "true" | ||
serviceAccountName: otel-collector-sa | ||
automountServiceAccountToken: true | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: otel-collector | ||
namespace: spanner-autoscaler # kpt-set: ${namespace} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: otel-collector | ||
ports: | ||
- protocol: TCP | ||
port: 4317 | ||
targetPort: 4317 |
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
49 changes: 49 additions & 0 deletions
49
kubernetes/unified/autoscaler-config/otel-collector.yaml.template
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,49 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: otel-config | ||
namespace: spanner-autoscaler | ||
data: | ||
config.yaml: | | ||
--- | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
endpoint: 0.0.0.0:4317 | ||
|
||
processors: | ||
resourcedetection: | ||
detectors: [gcp] | ||
timeout: 10s | ||
override: false | ||
|
||
batch: | ||
# batch metrics before sending to reduce API usage | ||
send_batch_max_size: 200 | ||
send_batch_size: 200 | ||
timeout: 5s | ||
|
||
memory_limiter: | ||
# drop metrics if memory usage gets too high | ||
check_interval: 1s | ||
limit_percentage: 65 | ||
spike_limit_percentage: 20 | ||
|
||
exporters: | ||
googlecloud: | ||
timeout: 45s | ||
# Enable the debug exporter, and add to expoters pipeline to see the metrics being delivered | ||
# debug: | ||
# verbosity: detailed | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
processors: [resourcedetection, batch, memory_limiter] | ||
exporters: [googlecloud] | ||
telemetry: | ||
logs: | ||
# Change log level from "info" to "debug" to view detailed logs | ||
level: "info" |
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.