{"action":"closed","issue":{"url":"https://api.github.com/repos/wrouesnel/postgres_exporter/issues/238","repository_url":"https://api.github.com/repos/wrouesnel/postgres_exporter","labels_url":"https://api.github.com/repos/wrouesnel/postgres_exporter/issues/238/labels{/name}","comments_url":"https://api.github.com/repos/wrouesnel/postgres_exporter/issues/238/comments","events_url":"https://api.github.com/repos/wrouesnel/postgres_exporter/issues/238/events","html_url":"https://github.com/wrouesnel/postgres_exporter/issues/238","id":383166134,"node_id":"MDU6SXNzdWUzODMxNjYxMzQ=","number":238,"title":"Custom queries not working as expected","user":{"login":"hbksagar","id":2264639,"node_id":"MDQ6VXNlcjIyNjQ2Mzk=","avatar_url":"https://avatars2.githubusercontent.com/u/2264639?v=4","gravatar_id":"","url":"https://api.github.com/users/hbksagar","html_url":"https://github.com/hbksagar","followers_url":"https://api.github.com/users/hbksagar/followers","following_url":"https://api.github.com/users/hbksagar/following{/other_user}","gists_url":"https://api.github.com/users/hbksagar/gists{/gist_id}","starred_url":"https://api.github.com/users/hbksagar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbksagar/subscriptions","organizations_url":"https://api.github.com/users/hbksagar/orgs","repos_url":"https://api.github.com/users/hbksagar/repos","events_url":"https://api.github.com/users/hbksagar/events{/privacy}","received_events_url":"https://api.github.com/users/hbksagar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-21T15:19:11Z","updated_at":"2018-11-22T07:48:34Z","closed_at":"2018-11-22T07:48:34Z","author_association":"NONE","body":"I have appended following snippet to my queries.yml\r\n```\r\npg_long_running_queries:\r\n  query: \"SELECT pid as long_running_pid, now() - pg_stat_activity.query_start as long_running_duration, query as long_running_query, state as long_running_state FROM pg_stat_activity where now() - query_start > interval '5 minute' AND state != 'idle'\"\r\n  metrics:\r\n    - long_running_pid:\r\n        usage: \"LABEL\"\r\n        description: \"PID of the long running query\"\r\n    - long_running_duration:\r\n        usage: \"GAUGE\"\r\n        description: \"Duration of the long running query\"\r\n    - long_running_query:\r\n        usage: \"LABEL\"\r\n        description: \"Long running query\"\r\n    - long_running_state:\r\n        usage: \"LABEL\"\r\n        description: \"State of the long running query\"\r\n```\r\n\r\nThough there exist output in Postgres, there is no info in exporter output.\r\n\r\nBy mistake I incorrectly added metrics names then I started getting some output but wasn't useful\r\n```\r\npg_long_running_queries:\r\n  query: \"SELECT pid as long_running_pid, now() - pg_stat_activity.query_start as long_running_duration, query as long_running_query, state as long_running_state FROM pg_stat_activity where now() - query_start > interval '5 minute' AND state != 'idle'\"\r\n  metrics:\r\n    - pid:\r\n        usage: \"LABEL\"\r\n        description: \"PID of the long running query\"\r\n    - duration:\r\n        usage: \"GAUGE\"\r\n        description: \"Duration of the long running query\"\r\n    - query:\r\n        usage: \"LABEL\"\r\n        description: \"Long running query\"\r\n    - state:\r\n        usage: \"LABEL\"\r\n        description: \"State of the long running query\"\r\n```\r\n\r\nOutput because of above query:\r\n```\r\n# HELP long_running_queries_long_running_pid Unknown metric from long_running_queries\r\n# TYPE long_running_queries_long_running_pid untyped\r\nlong_running_queries_long_running_pid{pid=\"7905\",query=\"7905\",state=\"7905\"} 7905\r\nlong_running_queries_long_running_pid{pid=\"7906\",query=\"7906\",state=\"7906\"} 7906\r\n```\r\n\r\nAm I using this correctly?"}}
{"actor":{"display_login":"hbksagar"}}