Skip to content

Expose a metric/message on the landing page that queries.yaml didn't load #125

Closed
@bchanan03

Description

@bchanan03

Hi
I have created the following configmap
but when connecting to promethuse console (port-forward) i cannot see any metrics.
I have added some of mine...same issue

Q: should there be a metric name: pg_database_size_name? or pg_database_size_owner

Can you write a small guidelines on how to use queries.yml and configmap
Thanks
Chanan

apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-exporter-configmap
  labels:
    app: postgres-exporter
    monitoring: prometheus
data:
  queries.yaml  : |+
    pg_replication:
      query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))::INT as lag"
      metrics:
        - lag:
            usage: "GAUGE"
            description: "Replication lag behind master in seconds"

    pg_postmaster:
      query: "SELECT pg_postmaster_start_time as start_time_seconds from pg_postmaster_start_time()"
      metrics:
        - start_time_seconds:
            usage: "GAUGE"
            description: "Time at which postmaster started"

    pg_stat_user_tables:
      query: "SELECT schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze, vacuum_count, autovacuum_count, analyze_count, autoanalyze_count FROM pg_stat_user_tables"
      metrics:
            - schemaname:
                usage: "LABEL"
                description: "Name of the schema that this table is in"
            - relname:
                usage: "LABEL"
                description: "Name of this table"
            - seq_scan:
                usage: "COUNTER"
                description: "Number of sequential scans initiated on this table"
            - seq_tup_read:
                usage: "COUNTER"
                description: "Number of live rows fetched by sequential scans"
            - idx_scan:
                usage: "COUNTER"
                description: "Number of index scans initiated on this table"
            - idx_tup_fetch:
                usage: "COUNTER"
                description: "Number of live rows fetched by index scans"
            - n_tup_ins:
                usage: "COUNTER"
                description: "Number of rows inserted"
            - n_tup_upd:
                usage: "COUNTER"
                description: "Number of rows updated"
            - n_tup_del:
                usage: "COUNTER"
                description: "Number of rows deleted"
            - n_tup_hot_upd:
                usage: "COUNTER"
                description: "Number of rows HOT updated (i.e., with no separate index update required)"
            - n_live_tup:
                usage: "GAUGE"
                description: "Estimated number of live rows"
            - n_dead_tup:
                usage: "GAUGE"
                description: "Estimated number of dead rows"
            - n_mod_since_analyze:
                usage: "GAUGE"
                description: "Estimated number of rows changed since last analyze"
            - last_vacuum:
                usage: "GAUGE"
                description: "Last time at which this table was manually vacuumed (not counting VACUUM FULL)"
            - last_autovacuum:
                usage: "GAUGE"
                description: "Last time at which this table was vacuumed by the autovacuum daemon"
            - last_analyze:
                usage: "GAUGE"
                description: "Last time at which this table was manually analyzed"
            - last_autoanalyze:
                usage: "GAUGE"
                description: "Last time at which this table was analyzed by the autovacuum daemon"
            - vacuum_count:
                usage: "COUNTER"
                description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)"
            - autovacuum_count:
                usage: "COUNTER"
                description: "Number of times this table has been vacuumed by the autovacuum daemon"
            - analyze_count:
                usage: "COUNTER"
                description: "Number of times this table has been manually analyzed"
            - autoanalyze_count:
                usage: "COUNTER"
                description: "Number of times this table has been analyzed by the autovacuum daemon"

        pg_database:
          query: " SELECT pg_database.datname, pg_database_size(pg_database.datname) as size FROM pg_database"
          metrics:
            - datname:
                usage: "LABEL"
                description: "Name of the database"
            - size:
                usage: "GAUGE"
                description: "Disk space used by the database"

        pg_index_usage:
          query: "select relname, case when (seq_scan + idx_scan) != 0  then 100.0 * idx_scan / (seq_scan + idx_scan) else 0 end as percent_of_times_index_used, n_live_tup AS rows_in_table from pg_stat_user_tables order by n_live_tup desc"
          metrics:
            - relname:
                usage: "COUNTER"
                description: "relname"
            - percent_of_times_index_used:
                usage: "COUNTER"
                description: "Percentage of time index was used"
            - rows_in_table:
                usage: "COUNTER"
                description: "Number of rows in table"

        pg_database_size:
          query: "select d.datname as name, pg_catalog.pg_get_userbyid(d.datdba) as owner, case when pg_catalog.has_database_privilege(d.datname, 'connect') then pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname)) else 'no access' end as size from pg_catalog.pg_database d ordeby case when pg_catalog.has_database_privilege(d.datname, 'connect') then pg_catalog.pg_database_size(d.datname) else null end;"
          metrics:
            - name:
                usage: "LABEL"
                description: "database name"
            - owner:
                usage: "LABEL"
                description: "database owner name"
            - size:
                usage: "COUNTER"
                description: "database size"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions