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 galaxy job radar visualization tool stats collection role and scripts #1395

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion group_vars/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,19 @@ telegraf_plugins_extra:
- timeout = "60s"
- data_format = "influx"
- interval = "2m"

galaxy_job_radar_visualization_stats:
plugin: "exec"
config:
- commands = [
"{{ custom_telegraf_env }} /usr/bin/galaxy_failed_jobs_by_destination.sh",
"{{ custom_telegraf_env }} /usr/bin/galaxy_most_used_tools_by_destination.sh",
"{{ custom_telegraf_env }} /usr/bin/galaxy_num_anonymous_jobs_by_destination.sh",
"{{ custom_telegraf_env }} /usr/bin/galaxy_unique_users_job_count_by_destination.sh",
"{{ custom_telegraf_env }} /usr/bin/galaxy_longest_running_jobs_by_destination.sh",
]
- timeout = "240s"
- data_format = "influx"
- interval = "1h"
Copy link
Member

Choose a reason for hiding this comment

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

Those queries are very expensive arn't they? Do we really need to run them this often?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, The SQL queries I have added are optimized as much as possible (I think when I timed their executions, they completed in less than a few seconds (Yes, a few seconds might be an expensive operation)). The interval depends on how often we want the data in the Galaxy Job Radar to be updated for visualization and how "real" the "real-time" data should be for that.

Copy link
Member

Choose a reason for hiding this comment

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

Stefan and me have the suspicion that one of our many queries for Grafana is causing our DB problems.
I'm just afraid of we add more of those. Please merge this in and observe how it is going, but my maybe we should also:

  • increase the interval
  • maybe we need to add new indices somewhere
  • maybe we need to fill larger influx-tables and then do the selection in the influx side.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like dumping the data into the influx tables and then processing it there. Let me see the possibilities.


# Role: hxr.monitor-cluster
monitor_condor: true
Expand Down
1 change: 1 addition & 0 deletions maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
# - usegalaxy-eu.fix-user-quotas
- usegalaxy-eu.remove-orphan-condor-jobs
- ssh_hardening
- usegalaxy-eu.job-radar-stats-influxdb
- dj-wasabi.telegraf
# - usegalaxy-eu.fix-stop-ITs
- usegalaxy-eu.logrotate
Expand Down
2 changes: 2 additions & 0 deletions roles/usegalaxy-eu.job-radar-stats-influxdb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# defaults file for galaxy-job-radar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Description: This script uses gxadmin to get the errored jobs from the Galaxy server in the last 1 hour and outputs the count of errored jobs by destination in InfluxDB line protocol format.

gxadmin tsvquery errored-jobs 1 | awk '{count[$7]++} END {for (dest in count) printf "errored_jobs_by_destination,destination_id=%s,state=errored count=%d\n", dest, count[dest]}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Description: This script uses gxadmin to get the longest running jobs on the Galaxy server and outputs the longest running jobs by destination in InfluxDB line protocol format.

gxadmin query q "COPY (SELECT j.id, j.tool_id, j.destination_id, EXTRACT(EPOCH FROM (NOW() - jsh.running_since)) / 3600 AS hours_since_running FROM job j JOIN LATERAL (SELECT MIN(create_time) AS running_since FROM job_state_history jsh WHERE jsh.job_id = j.id AND jsh.state = 'running') jsh ON true WHERE j.state = 'running' ORDER BY hours_since_running DESC) TO STDOUT WITH (FORMAT CSV, HEADER FALSE, DELIMITER ',');" | awk -F, '{printf "longest_running_jobs,job_id=%s,tool_id=%s,destination_id=%s hours_since_running=%d\n", $1, $2, $3, $4}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Description: This script uses gxadmin to count the most used tools on the Galaxy server and outputs the count of most used tools by destination in InfluxDB line protocol format.

gxadmin query q "COPY (SELECT regexp_replace(tool_id, '/[^/]+$', '') AS tool_id_no_version, destination_id, COUNT(*) AS job_count FROM job WHERE create_time >= (now() AT TIME ZONE 'UTC' - INTERVAL '1 hours') AND tool_id ILIKE 'toolshed%' AND destination_id IS NOT NULL GROUP BY tool_id_no_version, destination_id ORDER BY job_count DESC) TO STDOUT WITH (FORMAT CSV, HEADER FALSE, DELIMITER ',');" | awk -F, '{printf "most_used_tools_by_destination,tool_id=%s,destination_id=%s job_count=%d\n", $1, $2, $3}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Description: This script uses gxadmin to count the number of jobs run by anonymous users on the Galaxy server and outputs the count of anonymous users by destination in InfluxDB line protocol format.

gxadmin csvquery queue-detail | awk -F',' '/Anonymous User/ {count[$9]++} END {for (id in count) print "anonymous_user_jobs_by_destination,destination_id=" id ", count=" count[id]}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# Description: This script uses gxadmin to count the unique users running jobs on the Galaxy server and outputs the count of unique users by destination in InfluxDB line protocol format.

gxadmin csvquery queue-detail | grep running | awk -F, '{users[$9][$5]=1} END {for (dest in users) {count=0; for (user in users[dest]) count++; printf "num_unique_users_jobs_by_destination,destination_id=%s,state=running unique_user_count=%d\n", dest, count}}'
54 changes: 54 additions & 0 deletions roles/usegalaxy-eu.job-radar-stats-influxdb/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
galaxy_info:
author: your name
description: Galaxy stats collection scripts for galaxy job radar visualization tool
company: your company (optional)

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)

min_ansible_version: 2.1

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

galaxy_tags:
[]
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies:
[]
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
14 changes: 14 additions & 0 deletions roles/usegalaxy-eu.job-radar-stats-influxdb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Copy the gxadmin bash scripts for collecting stats for galaxy job radar visualization tool
ansible.builtin.copy:
src: '{{ item }}'
dest: 'usr/bin/{{ item }}'
owner: 'root'
group: 'root'
mode: 0755
loop:
- 'galaxy_failed_jobs_by_destination.sh'
- 'galaxy_most_used_tools_by_destination.sh'
- 'galaxy_num_anonymous_jobs_by_destination.sh'
- 'galaxy_unique_users_job_count_by_destination.sh'
- 'galaxy_longest_running_jobs_by_destination.sh'
Loading