-
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.
prometheus: add start up and shutdown scrape
This change does the following: - Add an entrypoint for the sidecar that can control the collector - Add start up scraping with a 10s offset - Add scraping before shutdown - Add metric adjuster that falls back on collector start time - Add unit test and hook things up to the prometheus pipeline - Add sample app that dies after a request and a cloudbuild taml file to run it Change-Id: I33b4a8af0fd9568c4f0f258e95c600e1b9c6df0d Signed-off-by: Ridwan Sharif <[email protected]>
- Loading branch information
1 parent
316c815
commit 182598e
Showing
30 changed files
with
1,020 additions
and
216 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.git | ||
Dockerfile | ||
.dockerignore |
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 |
---|---|---|
|
@@ -7,12 +7,12 @@ RUN go install github.com/client9/misspell/cmd/[email protected] \ | |
&& go install github.com/golangci/golangci-lint/cmd/[email protected] \ | ||
&& go install github.com/google/[email protected] | ||
RUN apt update && apt install -y make | ||
RUN make build-collector | ||
RUN make build | ||
|
||
FROM alpine:3 | ||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /sidecar/bin/rungmpcol /rungmpcol | ||
COPY collector-config.yaml /etc/rungmp/config.yaml | ||
COPY --from=builder /sidecar/bin/run-gmp-entrypoint /run-gmp-entrypoint | ||
COPY collector-config.yaml /etc/rungmp/config.yml | ||
|
||
ENTRYPOINT ["/rungmpcol"] | ||
CMD ["--config", "/etc/rungmp/config.yaml"] | ||
ENTRYPOINT ["/run-gmp-entrypoint"] |
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,104 @@ | ||
# 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. | ||
|
||
steps: | ||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["build", "-t", "${_IMAGE_APP}", "./sample-apps/single-req-app"] | ||
id: BUILD_SAMPLE_APP | ||
waitFor: ["-"] | ||
|
||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["push", "${_IMAGE_APP}"] | ||
id: PUSH_SAMPLE_APP | ||
waitFor: | ||
- BUILD_SAMPLE_APP | ||
|
||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["build", "-t", "${_IMAGE_COLLECTOR}", "."] | ||
id: BUILD_COLLECTOR | ||
waitFor: ["-"] | ||
|
||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["push", "${_IMAGE_COLLECTOR}"] | ||
id: PUSH_COLLECTOR | ||
waitFor: | ||
- BUILD_COLLECTOR | ||
|
||
- name: "ubuntu" | ||
env: | ||
- "IMAGE_APP=${_IMAGE_APP}" | ||
- "IMAGE_COLLECTOR=${_IMAGE_COLLECTOR}" | ||
script: | | ||
sed -i s@%OTELCOL_IMAGE%@${IMAGE_COLLECTOR}@g run-service.yaml | ||
sed -i s@%SAMPLE_APP_IMAGE%@${IMAGE_APP}@g run-service.yaml | ||
id: REPLACE_YAML_VALUE | ||
waitFor: ["-"] | ||
|
||
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" | ||
entrypoint: gcloud | ||
args: | ||
[ | ||
"run", | ||
"services", | ||
"replace", | ||
"run-service.yaml", | ||
"--region", | ||
"${_REGION}", | ||
] | ||
id: DEPLOY_MULTICONTAINER | ||
waitFor: | ||
- PUSH_SAMPLE_APP | ||
- PUSH_COLLECTOR | ||
- REPLACE_YAML_VALUE | ||
|
||
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim" | ||
entrypoint: gcloud | ||
args: | ||
[ | ||
"run", | ||
"services", | ||
"set-iam-policy", | ||
"run-gmp-sidecar-service", | ||
"policy.yaml", | ||
"--region", | ||
"${_REGION}", | ||
"--quiet", | ||
] | ||
id: ALLOW_UNAUTHENTICATED | ||
waitFor: | ||
- DEPLOY_MULTICONTAINER | ||
|
||
substitutions: | ||
_REGION: us-east1 | ||
_REGISTRY: ${_REGION}-docker.pkg.dev/${PROJECT_ID}/run-gmp | ||
_IMAGE_APP: ${_REGISTRY}/sample-app | ||
_IMAGE_COLLECTOR: ${_REGISTRY}/collector | ||
_SA_NAME: run-gmp-sa | ||
|
||
images: | ||
- ${_IMAGE_APP} | ||
- ${_IMAGE_COLLECTOR} | ||
|
||
# comment out the following line if you want to run Cloud Build with the existing | ||
# service account with the following roles. | ||
# * roles/iam.serviceAccountUser | ||
# * roles/storage.objectViewer | ||
# * roles/logging.logWriter | ||
# * roles/artifactregistry.createOnPushWriter | ||
# * roles/run.admin | ||
serviceAccount: "projects/${PROJECT_ID}/serviceAccounts/${_SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" | ||
|
||
options: | ||
dynamic_substitutions: true | ||
logging: CLOUD_LOGGING_ONLY |
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
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
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.