From d253e65573a2276bcb8bb95cb5323bbc570fb55a Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 24 Sep 2025 15:41:39 -0400 Subject: [PATCH 1/3] Collect workflow and tool landing requests --- group_vars/galaxy_db_servers/vars.yaml | 30 ++++++++ .../telegraf/tool_landing_requests.sh.j2 | 72 +++++++++++++++++++ .../telegraf/workflow_landing_requests.sh.j2 | 72 +++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 templates/telegraf/tool_landing_requests.sh.j2 create mode 100644 templates/telegraf/workflow_landing_requests.sh.j2 diff --git a/group_vars/galaxy_db_servers/vars.yaml b/group_vars/galaxy_db_servers/vars.yaml index b19aa773..9b84680b 100644 --- a/group_vars/galaxy_db_servers/vars.yaml +++ b/group_vars/galaxy_db_servers/vars.yaml @@ -1,5 +1,17 @@ --- +galaxy_db_servers_group_templates: + - src: templates/telegraf/workflow_landing_requests.sh.j2 + dest: "/srv/galaxy/{{ galaxy_instance_codename }}/workflow_landing_requests.sh" + owner: root + group: root + mode: '0755' + - src: templates/telegraf/tool_landing_requests.sh.j2 + dest: "/srv/galaxy/{{ galaxy_instance_codename }}/tool_landing_requests.sh" + owner: root + group: root + mode: '0755' + # Always restart PostgreSQL on exit galaxy_db_servers_group_systemd_overrides: - name: "postgresql-{{ __postgresql_version_dotless }}" @@ -169,6 +181,24 @@ galaxy_db_servers_group_telegraf_plugins_extra: - interval = "1m" - '[inputs.exec.tags]' - ' influxdb_database = "{{ galaxy_instance_codename }}_sql"' + galaxy_workflow_landing_requests: + plugin: "exec" + config: + - commands = ["/srv/galaxy/{{ galaxy_instance_codename }}/workflow_landing_requests.sh"] + - timeout = "30s" + - data_format = "influx" + - interval = "5m" + - '[inputs.exec.tags]' + - ' influxdb_database = "{{ galaxy_instance_codename }}_sql"' + galaxy_tool_landing_requests: + plugin: "exec" + config: + - commands = ["/srv/galaxy/{{ galaxy_instance_codename }}/tool_landing_requests.sh"] + - timeout = "30s" + - data_format = "influx" + - interval = "5m" + - '[inputs.exec.tags]' + - ' influxdb_database = "{{ galaxy_instance_codename }}_sql"' galaxy_disk_usage: plugin: "exec" config: diff --git a/templates/telegraf/tool_landing_requests.sh.j2 b/templates/telegraf/tool_landing_requests.sh.j2 new file mode 100644 index 00000000..7f571d5a --- /dev/null +++ b/templates/telegraf/tool_landing_requests.sh.j2 @@ -0,0 +1,72 @@ +#!/bin/bash +set -euo pipefail + +# Query tool_landing_request table for metrics +# Output in InfluxDB line protocol format for Telegraf + +PGDATABASE="galaxy_{{ galaxy_instance_codename }}" + +# Total tool landing requests +total=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM tool_landing_request;") +echo "tool_landing_requests_total value=${total}i" + +# Requests by day (last 30 days) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '30 days' +GROUP BY DATE(create_time) +ORDER BY day; +EOF + echo "tool_landing_requests_daily,day=${day} count=${count}i" +done + +# Requests by tool_id (top 10) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '7 days' +GROUP BY tool_id +ORDER BY count DESC +LIMIT 10; +EOF + tool_id_escaped=$(echo "$tool_id" | sed 's/[,= ]/\\&/g') + echo "tool_landing_requests_by_tool,tool_id=${tool_id_escaped} count=${count}i" +done + +# Public vs Private requests (last 24 hours) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '24 hours' +GROUP BY public; +EOF + echo "tool_landing_requests_visibility,visibility=${visibility} count=${count}i" +done + +# Requests with user vs anonymous (last 24 hours) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '24 hours' +GROUP BY (user_id IS NULL); +EOF + echo "tool_landing_requests_user_type,user_type=${user_type} count=${count}i" +done + +# Recent activity (last 1 hour, 24 hours, 7 days) +recent_1h=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM tool_landing_request WHERE create_time >= NOW() - INTERVAL '1 hour';") +recent_24h=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM tool_landing_request WHERE create_time >= NOW() - INTERVAL '24 hours';") +recent_7d=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM tool_landing_request WHERE create_time >= NOW() - INTERVAL '7 days';") + +echo "tool_landing_requests_recent,period=1h value=${recent_1h}i" +echo "tool_landing_requests_recent,period=24h value=${recent_24h}i" +echo "tool_landing_requests_recent,period=7d value=${recent_7d}i" diff --git a/templates/telegraf/workflow_landing_requests.sh.j2 b/templates/telegraf/workflow_landing_requests.sh.j2 new file mode 100644 index 00000000..ca17b495 --- /dev/null +++ b/templates/telegraf/workflow_landing_requests.sh.j2 @@ -0,0 +1,72 @@ +#!/bin/bash +set -euo pipefail + +# Query workflow_landing_request table for metrics +# Output in InfluxDB line protocol format for Telegraf + +PGDATABASE="galaxy_{{ galaxy_instance_codename }}" + +# Total workflow landing requests +total=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM workflow_landing_request;") +echo "workflow_landing_requests_total value=${total}i" + +# Requests by day (last 30 days) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '30 days' +GROUP BY DATE(create_time) +ORDER BY day; +EOF + echo "workflow_landing_requests_daily,day=${day} count=${count}i" +done + +# Requests by workflow_id (top 10) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '7 days' +GROUP BY workflow_id +ORDER BY count DESC +LIMIT 10; +EOF + workflow_id_escaped=$(echo "$workflow_id" | sed 's/[,= ]/\\&/g') + echo "workflow_landing_requests_by_workflow,workflow_id=${workflow_id_escaped} count=${count}i" +done + +# Public vs Private requests (last 24 hours) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '24 hours' +GROUP BY public; +EOF + echo "workflow_landing_requests_visibility,visibility=${visibility} count=${count}i" +done + +# Requests with user vs anonymous (last 24 hours) +psql -d "$PGDATABASE" -t -A -F',' <= NOW() - INTERVAL '24 hours' +GROUP BY (user_id IS NULL); +EOF + echo "workflow_landing_requests_user_type,user_type=${user_type} count=${count}i" +done + +# Recent activity (last 1 hour, 24 hours, 7 days) +recent_1h=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM workflow_landing_request WHERE create_time >= NOW() - INTERVAL '1 hour';") +recent_24h=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM workflow_landing_request WHERE create_time >= NOW() - INTERVAL '24 hours';") +recent_7d=$(psql -d "$PGDATABASE" -t -A -c "SELECT COUNT(*) FROM workflow_landing_request WHERE create_time >= NOW() - INTERVAL '7 days';") + +echo "workflow_landing_requests_recent,period=1h value=${recent_1h}i" +echo "workflow_landing_requests_recent,period=24h value=${recent_24h}i" +echo "workflow_landing_requests_recent,period=7d value=${recent_7d}i" From c9541c9eb55458c5f5d52532ae498fadcf86e712 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 25 Sep 2025 10:59:01 -0400 Subject: [PATCH 2/3] Use /usr/local/bin for landing request scripts instead of non-existent /srv/galaxy path --- group_vars/galaxy_db_servers/vars.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/group_vars/galaxy_db_servers/vars.yaml b/group_vars/galaxy_db_servers/vars.yaml index 9b84680b..00892d19 100644 --- a/group_vars/galaxy_db_servers/vars.yaml +++ b/group_vars/galaxy_db_servers/vars.yaml @@ -2,12 +2,12 @@ galaxy_db_servers_group_templates: - src: templates/telegraf/workflow_landing_requests.sh.j2 - dest: "/srv/galaxy/{{ galaxy_instance_codename }}/workflow_landing_requests.sh" + dest: "/usr/local/bin/workflow_landing_requests.sh" owner: root group: root mode: '0755' - src: templates/telegraf/tool_landing_requests.sh.j2 - dest: "/srv/galaxy/{{ galaxy_instance_codename }}/tool_landing_requests.sh" + dest: "/usr/local/bin/tool_landing_requests.sh" owner: root group: root mode: '0755' @@ -184,7 +184,7 @@ galaxy_db_servers_group_telegraf_plugins_extra: galaxy_workflow_landing_requests: plugin: "exec" config: - - commands = ["/srv/galaxy/{{ galaxy_instance_codename }}/workflow_landing_requests.sh"] + - commands = ["/usr/local/bin/workflow_landing_requests.sh"] - timeout = "30s" - data_format = "influx" - interval = "5m" @@ -193,7 +193,7 @@ galaxy_db_servers_group_telegraf_plugins_extra: galaxy_tool_landing_requests: plugin: "exec" config: - - commands = ["/srv/galaxy/{{ galaxy_instance_codename }}/tool_landing_requests.sh"] + - commands = ["/usr/local/bin/tool_landing_requests.sh"] - timeout = "30s" - data_format = "influx" - interval = "5m" From 5c32c3c3dcf1bfb265bb280486346f1663b982e1 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Mon, 29 Sep 2025 10:25:42 -0400 Subject: [PATCH 3/3] Enable ansible_become for galaxy-db server and remove conflicting comments --- inventory/tacc.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/inventory/tacc.yaml b/inventory/tacc.yaml index 25b51ac9..d999a22a 100644 --- a/inventory/tacc.yaml +++ b/inventory/tacc.yaml @@ -230,9 +230,7 @@ all: galaxy-main4.tacc.utexas.edu: ansible_become: true galaxy-db.tacc.utexas.edu: - # annoyingly, this overrides become on plays - #ansible_become: false - ansible_user: root + ansible_become: true galaxy-vgp.tacc.utexas.edu: #ansible_become: false ansible_user: root