Skip to content

Conversation

@marcleblanc2
Copy link
Contributor

@marcleblanc2 marcleblanc2 commented Oct 9, 2024

For PS-83: Create pgsql datasource in Grafana

Checklist

Test plan

Tested on test instance for upgrades and new installs, with and without the env vars configured

Alternatives Considered

I tried to change the existing ConfigMap just mounted as a single file inside the directory, so then I could just add Postgres via a separate ConfigMap via subDir mount, but that threw Grafana for a loop because the datasources.yml file is not declarative (ex. Terraform), but just an input ingestion method to Grafana's config state (maintained in a MongoDB inside the Grafana container?), and when the datasources.yml file gets a new inode on an existing instance, Grafana fails to start up, because we have default:true on Prometheus, so Grafana seeing the same Prometheus data source in a new file at a new inode, so it errors out like we're trying to declare a second Prometheus datasource as also default, without first deleting the first one... we'd have to also migrate the Grafana config on existing instances by declaring a delete datasources block to delete the existing default Prometheus before creating a "new" one, and if we're going through all that, I'd say we should also set prune:true to cover us for the next time someone needs to change something, but that feature's not available in v7.5 🤦

@marcleblanc2 marcleblanc2 requested review from a team and DaedalusG and removed request for a team October 10, 2024 00:12
@marcleblanc2 marcleblanc2 requested a review from a team October 10, 2024 00:12
Comment on lines +18 to +26
- name: pgsql
type: postgres
url: $PGHOST:$PGPORT
user: $PGGRAFANAUSER
database: $PGDATABASE
secureJsonData:
password: $PGGRAFANAPASSWORD
jsonData:
sslmode: $PGSSLMODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this optional with something like {{- if .Values.grafana.postgres.enabled }} wrapping it?
I'd be worried about this being on by default.

Copy link
Contributor Author

@marcleblanc2 marcleblanc2 Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grafana doesn't create this datasource if the env vars are not defined, so the switch to enable it is defining all of these env vars on the Grafana container; this process is consistent across all deployment methods, which is a big win.

Adding another config flag would be redundant, and would increase the delta of maintaining the Cody Airgapped Analytics solution between different deployment methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdpleiness had a call with @marcleblanc2 and discussed this, things look okay and yea grafana shouldn't deploy these unless the specific env vars are set. They're only set by default via our helpers in frontend and migrator

@marcleblanc2 marcleblanc2 merged commit 97d9472 into main Oct 10, 2024
@marcleblanc2 marcleblanc2 deleted the marc/cody-airgapped-analytics branch October 10, 2024 20:06
enriquegh pushed a commit that referenced this pull request Jul 10, 2025
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

Successfully merging this pull request may close these issues.

4 participants