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

[+] add new stat activity grid report #521

Merged

Conversation

pmpetit
Copy link
Contributor

@pmpetit pmpetit commented Oct 28, 2022

Hello,
One of my collegue Manu G. has created a new report on stat-activity, to match our needs.
I have tested it, i think we should share.

Example
image

@pashagolub
Copy link
Collaborator

Can you please describe this dashboard in a few words?
Thanks in advance!

@pmpetit
Copy link
Contributor Author

pmpetit commented Nov 17, 2022

This dashboard represents the number of sessions taht are executing the query, just like oracle does in oem (Oracle Entreprise Mngt).
For example in yellow at 9h55, we can see that 4 sessions were executing
SELECT /* getReception etc... (the second query)

It is a well known dashboard in oracle world.

@pashagolub
Copy link
Collaborator

Thanks a lot for clarifications!

@pashagolub
Copy link
Collaborator

During testing this grid I got an error from Grafana:

Templating
Failed to upgrade legacy queries Datasource pgwatch-metrics was not found
Templating [dbname]
Error updating options: Datasource pgwatch-metrics was not found

Did you see such messages on a fresh installs with your dashboards?

@pashagolub
Copy link
Collaborator

I noticed that only your dashboartd.json contains "datasource": "pgwatch-metrics" string. Can this be the reason?

@pmpetit
Copy link
Contributor Author

pmpetit commented Dec 2, 2022

I have a check

@pashagolub
Copy link
Collaborator

I'm not sure what am I doing wrong but it's just doesn't work:
image

Would you please try to reproduce my steps. In the local pgwatch2 repo execute:

$ ./build-docker-postgres.sh

$  docker run -d --restart=unless-stopped --name pw2 -p 3000:3000 -p 8080:
8080 -p 127.0.0.1:5432:5432  -e PW2_TESTDB=true   cybertec/pgwatch2-postgres:latest

Then try to open http://localhost:3000/d/stat-activity/stat-activity

@pmpetit
Copy link
Contributor Author

pmpetit commented Dec 11, 2022

Hi,
i have troubleshooted, it is ok now:

  • add this metric to default "FULL" template (we were using only the preset-config.yaml file), that's why you could not see it in your test.
  • troubleshoot some typo (epoch was missing in the metric)

i have tested with your docker run command line (and pgbench):
image

i wonder if i should still limit to 100ms:

select /* pgwatch2_generated */
  (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
  s.query as query,
  count(*) as count
from get_stat_activity() s
where s.datname = current_database()
  and s.state = 'active'
  and s.backend_type = 'client backend'
  and s.pid != pg_backend_pid()
  and now() - s.query_start > '100ms'::interval
group by s.query;

or set duration to "10 ms" and filter at dashboard level.

for the moment, i fix it to 100ms.

@pashagolub
Copy link
Collaborator

Excellent! Thank you.

@pashagolub pashagolub changed the title feat (stat_activity): new stat activity grid report [+] add new stat activity grid report Dec 11, 2022
@pashagolub pashagolub merged commit 9055498 into cybertec-postgresql:master Dec 11, 2022
pashagolub added a commit to cybertec-postgresql/pgwatch3 that referenced this pull request Feb 17, 2023
pashagolub added a commit to cybertec-postgresql/pgwatch3 that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants