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

gcp_stackdriver_logs: 401 Unauthorised each hour #19614

Closed
garethpelly opened this issue Jan 12, 2024 · 5 comments
Closed

gcp_stackdriver_logs: 401 Unauthorised each hour #19614

garethpelly opened this issue Jan 12, 2024 · 5 comments
Labels
sink: gcp_stackdriver_logs Anything `gcp_stackdriver_logs` sink related type: bug A code related bug.

Comments

@garethpelly
Copy link
Contributor

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

Each ~hour we are observing "Http status: 401 Unauthorized" in our vector logs coming from the gcp_stackdriver_logs sink.
Vector is running in GKE as a headless service and consuming logs from kafka, we do not utilise the credentials_path and instead rely on the Service Account to authenticate. The problem resolves itself after a 2/3 minute period however my understanding is that these logs are not retried and are therefore discarded.

Configuration

type = "gcp_stackdriver_logs"
inputs = ["final_cleanup"]
log_id = "{{ type }}"
project_id = "centralized-logging"
severity_key = "log_level"

batch.max_events = 1000
batch.max_bytes = 9900000

resource.type = "{{ resource_type }}"
resource.project_id = "{{ gcp_project_id }}"
resource.instance_id = "{{ hostname }}"

Version

0.34.1-distroless-libc

Debug Output

No response

Example Data

No response

Additional Context

No response

References

@garethpelly garethpelly added the type: bug A code related bug. label Jan 12, 2024
@jszwedko
Copy link
Member

You are correct, it seems like those requests are not retried. I'd argue they should be (per #10870), in addition to refreshing the token before it expires.

Retry logic:

fn should_retry_response(&self, response: &T) -> RetryAction {
let status = (self.func)(response);
match status {
StatusCode::TOO_MANY_REQUESTS => RetryAction::Retry("too many requests".into()),
StatusCode::NOT_IMPLEMENTED => {
RetryAction::DontRetry("endpoint not implemented".into())
}
_ if status.is_server_error() => {
RetryAction::Retry(format!("Http Status: {}", status).into())
}
_ if status.is_success() => RetryAction::Successful,
_ => RetryAction::DontRetry(format!("Http status: {}", status).into()),
}
}

@jszwedko jszwedko added the sink: gcp_stackdriver_logs Anything `gcp_stackdriver_logs` sink related label Jan 12, 2024
@garethpelly
Copy link
Contributor Author

garethpelly commented May 10, 2024

Coming back to this, it seems as though the root issue relates to running more than 1 gcp_stackdriver_logs sink (we had a separate sink sending a subset of logs to a different GCP project).
Vector's handling of the authentication token refreshes seems to (perhaps) have a timing/race issue when more than one sink is in play, when we removed the additional sink the 401s were no longer observed.

@garethpelly
Copy link
Contributor Author

Update: The 401s have returned since we scaled back to a single gcp_stackdriver_logs sink.

@garethpelly
Copy link
Contributor Author

@jszwedko I've taken a stab at changing how the token is refreshed in #20574.

@garethpelly
Copy link
Contributor Author

Closing. Fixed in #20574

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

No branches or pull requests

2 participants