-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
confgenerator: add support for RunMonitoring configs
This change does the following: - Adds confgenerator for `RunMonitoring` - Adds all structs required for the config - Adds golden test files for unit tests - Configures the entrypoint so it creates the config for the collector subprocess - Use secret manager for storing the configs Notes for reviewers: - Sorry this PR is long again - I wanted to add the skeleton for the config generation. The actual labels we will add by default and what should be used in the monitored resource are not yet solidified and will be done in a seperate PR based on discussion in go/run-gmp-config. In this PR, ignore what we're setting as labels. - We discussed this offline, this change has some duplication with the Ops Agent's confgenerator and prometheus-engine's PodMonitoring structs. We accept this added tech debt because the Ops Agents packages aren't super well suited to use as libraries for this sidecar (yet, not much work is needed to make this possible but its not a blocker), and the prometheus libraries used by the prometheus-engine have different interfaces from the ones we forked. We will prioritize fixing this up and simplifying the confgenerator after the MVP Change-Id: Ie57f82761544ebfd0612f8347ac5ab07a4a22edf
- Loading branch information
1 parent
182598e
commit f33f5c6
Showing
30 changed files
with
2,091 additions
and
120 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
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,27 @@ | ||
#!/bin/bash | ||
# Copyright 2023 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. | ||
|
||
set -ex | ||
|
||
PROJECT_ID=$(gcloud config get-value project) | ||
SA_NAME="run-gmp-sa" | ||
REGION="us-east1" | ||
|
||
gcloud run services delete run-gmp-sidecar-service --region ${REGION} --quiet | ||
gcloud secrets delete run-gmp-config | ||
gcloud artifacts repositories delete run-gmp \ | ||
--location=${REGION} \ | ||
--quiet | ||
gcloud iam service-accounts delete ${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com |
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 was deleted.
Oops, something went wrong.
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,89 @@ | ||
// Copyright 2023 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. | ||
|
||
package confgenerator | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/GoogleCloudPlatform/run-gmp-sidecar/confgenerator/otel" | ||
) | ||
|
||
type AgentSelfMetrics struct { | ||
Version string | ||
Port int | ||
} | ||
|
||
func (r AgentSelfMetrics) OTelReceiverPipeline() otel.ReceiverPipeline { | ||
return otel.ReceiverPipeline{ | ||
Receiver: otel.Component{ | ||
Type: "prometheus", | ||
Config: map[string]interface{}{ | ||
"config": map[string]interface{}{ | ||
"scrape_configs": []map[string]interface{}{{ | ||
"job_name": "run-gmp-sidecar", | ||
"scrape_interval": "1m", | ||
"static_configs": []map[string]interface{}{{ | ||
// TODO(b/196990135): Customization for the port number | ||
"targets": []string{fmt.Sprintf("0.0.0.0:%d", r.Port)}, | ||
}}, | ||
}}, | ||
}, | ||
}, | ||
}, | ||
Processors: []otel.Component{ | ||
otel.MetricsFilter( | ||
"include", | ||
"strict", | ||
"otelcol_process_uptime", | ||
"otelcol_process_memory_rss", | ||
"otelcol_grpc_io_client_completed_rpcs", | ||
"otelcol_googlecloudmonitoring_point_count", | ||
), | ||
otel.MetricsTransform( | ||
otel.RenameMetric("otelcol_process_uptime", "agent/uptime", | ||
// change data type from double -> int64 | ||
otel.ToggleScalarDataType, | ||
otel.AddLabel("version", r.Version), | ||
// remove service.version label | ||
otel.AggregateLabels("sum", "version"), | ||
), | ||
otel.RenameMetric("otelcol_process_memory_rss", "agent/memory_usage", | ||
// remove service.version label | ||
otel.AggregateLabels("sum"), | ||
), | ||
otel.RenameMetric("otelcol_grpc_io_client_completed_rpcs", "agent/api_request_count", | ||
// change data type from double -> int64 | ||
otel.ToggleScalarDataType, | ||
// TODO: below is proposed new configuration for the metrics transform processor | ||
// ignore any non "google.monitoring" RPCs (note there won't be any other RPCs for now) | ||
// - action: select_label_values | ||
// label: grpc_client_method | ||
// value_regexp: ^google\.monitoring | ||
otel.RenameLabel("grpc_client_status", "state"), | ||
// delete grpc_client_method dimension & service.version label, retaining only state | ||
otel.AggregateLabels("sum", "state"), | ||
), | ||
otel.RenameMetric("otelcol_googlecloudmonitoring_point_count", "agent/monitoring/point_count", | ||
// change data type from double -> int64 | ||
otel.ToggleScalarDataType, | ||
// Remove service.version label | ||
otel.AggregateLabels("sum", "status"), | ||
), | ||
), | ||
}, | ||
} | ||
} | ||
|
||
// intentionally not registered as a component because this is not created by users |
Oops, something went wrong.