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

No way to enable logs collection when using docker image #42

Open
sebasmagri opened this issue Apr 24, 2020 · 13 comments
Open

No way to enable logs collection when using docker image #42

sebasmagri opened this issue Apr 24, 2020 · 13 comments

Comments

@sebasmagri
Copy link

Seems like by default logs collection is not enabled when using the docker image without changes, and there's no environment variable or command switch to enable them.

@JordanP
Copy link

JordanP commented May 20, 2020

I have the same question: how does log collections work under Kubernetes ?

@lfittl
Copy link
Member

lfittl commented May 28, 2020

@JordanP We don't support log collection in Kubernetes today - though looking to add this in the future.

For @sebasmagri's initial question - Sebastian, were you looking to monitor Kubernetes pods, or were you targeting something external, like a cloud provider database?

(generally log collection is enabled by default in recent collector releases - if supported for the current platform, that is)

@sebasmagri
Copy link
Author

@lfittl it's for running the collector on ECS and monitoring RDS. We had to go with a custom docker image, but it's still pretty annoying that now the server names are forced to be the rds instance ID, since we create a lot of RDS instances dynamically and discard the old ones, being really a single server instance all the time.

@lfittl
Copy link
Member

lfittl commented May 28, 2020

@sebasmagri Ah - makes sense. You can use the following settings to override the system identifiers:

PGA_API_SYSTEM_ID
PGA_API_SYSTEM_TYPE
PGA_API_SYSTEM_SCOPE

You can see the defaults that get assigned here: https://github.com/pganalyze/collector/blob/master/config/identify_system.go#L15 (note you could e.g. choose to override PGA_API_SYSTEM_ID in your setup to have a stable server record)

@sebasmagri
Copy link
Author

Thanks for the pointer @lfittl !

We'd still like to be able to use the docker image as provided though, any chance that logging collection can be enabled by default for this use case?

@lfittl
Copy link
Member

lfittl commented May 28, 2020

@sebasmagri In the case where you are not using the instance ID in the hostname, utilizing the AWS_INSTANCE_ID variable should work (that, or the hostname, is what the collector checks against to determine which code path to take)

@JordanP
Copy link

JordanP commented Oct 2, 2020

@lfittl beside Kubernetes, does the Collector supports monitoring a PG instance running in a container ?

@lfittl
Copy link
Member

lfittl commented Oct 2, 2020

@JordanP There are two ways to do that, assuming you are referring to Postgres running inside a Docker container on a VM that you manage:

  1. Run the pganalyze-collector on the Docker host, and use the db_log_docker_tail setting - this will directly fetch the logs from the Docker engine. Note that this setting is mostly intended for our own development purposes, and is considered experimental.

  2. Run the pganalyze-collector in a Docker container. Have the Postgres container write the log output into a file that sits on a shared volume that the pganalyze-collector container has access to. Then use the LOG_LOCATION setting to specify that log file.

@JordanP
Copy link

JordanP commented Oct 2, 2020

Excellent ! Option 2 seems doable for us, nice !

@JordanP
Copy link

JordanP commented Oct 23, 2020

For the record, I managed to have log insights working in a Kubernetes cluster, with what you suggested: Run the pganalyze-collector in a Docker container. Have the Postgres container write the log output into a file that sits on a shared volume that the pganalyze-collector container has access to. Then use the LOG_LOCATION setting to specify that log file.

All good, thanks !

@rauanmayemir
Copy link
Contributor

Is there any follow-up on this?

I still think that it would be very convenient to have a way for kubernetes-managed log collectors like fluentd or vector push logs into pganalyze (whether to the collector or directly to the centralized ingest endpoint).

@ianstanton
Copy link
Contributor

@lfittl How realistic would it be to allow for pganalyze-collector to stream logs from a web socket? We're in a similar situation here, and our logs end up in Loki. We read these logs in other areas of our application via web socket.

@lfittl
Copy link
Member

lfittl commented Feb 18, 2024

See #503 for an implementation that should work in the typical Kubernetes environment using fluentbit for log routing (tested with CloudNativePG, need to do a bit more testing with other operators).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants