Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 Unauthorized for GCP Cloud Monitoring sink after an hour #17263

Closed
ansel1 opened this issue May 1, 2023 · 1 comment · Fixed by #17297
Closed

401 Unauthorized for GCP Cloud Monitoring sink after an hour #17263

ansel1 opened this issue May 1, 2023 · 1 comment · Fixed by #17297
Labels
type: bug A code related bug.

Comments

@ansel1
Copy link

ansel1 commented May 1, 2023

`### A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Using the GCP Cloud Monitoring sync, with vector running in a Pod in GKE. Using GCP workload identity (GCP service account linked to GKE service account) to authenticate to GCP.

This works fine for an hour, then we start seeing 401 errors. 100% reproducible.

Configuration

vector config for sink:

    [sinks.gcp]
    type = "gcp_stackdriver_metrics"
    inputs = [ "enrich_metrics" ]
    project_id = "${GCP_PROJECT_ID:?gcp_project_id must be supplied}"
    
    [sinks.gcp.resource]
    type = "gce_instance"
    project_id = "${GCP_PROJECT_ID:?gcp_project_id must be supplied}"
    instance_id = "cloud_containers"
    zone = "us-central1-a"

Source can be any metrics source. Vector is configured as a StatefulSet. The pod spec includes:

      serviceAccountName: vector
      nodeSelector:
        iam.gke.io/gke-metadata-server-enabled: "true"

The k8s service account is declared like this:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: vector
  labels:
    app.kubernetes.io/name: vector
    app.kubernetes.io/instance: vector
    app.kubernetes.io/component: Aggregator
    app.kubernetes.io/version: "latest-alpine"
  annotations:
    iam.gke.io/gcp-service-account: vector@our-gcp-project.iam.gserviceaccount.com
automountServiceAccountToken: true

Version

v0.29.1

Debug Output

2023-04-27T12:03:47.174065Z ERROR sink{component_kind="sink" component_id=gcp component_type=gcp_stackdriver_metrics component_name=gcp}:request{request_id=6983}: vector::sinks::util::sink: Response failed. response=Response { status: 401, version: HTTP/1.1, headers: {"www-authenticate": "Bearer realm="https://accounts.google.com/\", error="invalid_token"", "vary": "Origin", "vary": "X-Origin", "vary": "Referer", "content-type": "application/json; charset=UTF-8", "transfer-encoding": "chunked", "date": "Thu, 27 Apr 2023 12:03:47 GMT", "server": "ESF", "cache-control": "private", "x-xss-protection": "0", "x-frame-options": "SAMEORIGIN", "x-content-type-options": "nosniff"}, body: b"{\n "error": {\n "code": 401,\n "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.\",\n "status": "UNAUTHENTICATED",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.ErrorInfo",\n "reason": "ACCESS_TOKEN_EXPIRED",\n "domain": "googleapis.com",\n "metadata": {\n "method": "google.monitoring.v3.MetricService.CreateTimeSeries",\n "service": "monitoring.googleapis.com"\n }\n }\n ]\n }\n}\n" }

Example Data

No response

Additional Context

No response

References

#10828

@ansel1 ansel1 added the type: bug A code related bug. label May 1, 2023
@spencergilbert
Copy link
Contributor

Taking it look it doesn't look like the metrics sink calls the function that refreshes the authentication 🤔 digging into that, might be a super easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A code related bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants