Console templates

    Console templates are the most powerful way to create templates that can beeasily managed in source control. There is a learning curve though, so users newto this style of monitoring should try outGrafana first.

    Prometheus comes with an example set of consoles to get you going. These can befound at on a running Prometheus and willdisplay Node Exporter consoles if Prometheus is scraping Node Exporters with ajob="node" label.

    The example consoles have 5 parts:

    • A navigation bar on top
    • A menu on the left
    • Time controls on the bottom
    • The main content in the center, usually graphs

    The time controls allow changing of the duration and range of the graphs.Console URLs can be shared and will show the same graphs for others.

    Finally, the table on the right can be used to display statistics in a morecompact form than graphs.

    This is a basic console. It shows the number of tasks, how many of them are up,the average CPU usage, and the average memory usage in the right-hand-sidetable. The main content has a queries-per-second graph.

    The prom_right_table_head and prom_right_table_tail templates contain theright-hand-side table. This is optional.

    prom_query_drilldown is a template that will evaluate the expression passed to it, format it,and link to the expression in the . The firstargument is the expression. The second argument is the unit to use. The thirdargument is how to format the output. Only the first argument is required.

    • Not specified: Default Go display output.
    • humanize: Display the result using metric prefixes.
    • humanizeNoSmallPrefix: For absolute values greater than 1, display theresult using . Forabsolute values less than 1, display 3 significant digits. This is usefulto avoid units such as milliqueries per second that can be produced byhumanize.
    • humanize1024: Display the humanized result using a base of 1024 rather than 1000.This is usually used with B as the second argument to produce units such as KiB and .
    • printf.3g: Display 3 significant digits.Custom formats can be defined. Seeprom.lib for examples.

    The graph library is invoked as:

    1. <div id="queryGraph"></div>
    2. <script>
    3. node: document.querySelector("#queryGraph"),
    4. expr: "sum(rate(http_query_count{job='myjob'}[5m]))"
    5. })
    6. </script>

    The head template loads the required Javascript and CSS.

    Parameters to the graph library:

    If both expr and name are lists, they must be of the same length. The namewill be applied to the plots for the corresponding expression.

    • PromConsole.NumberFormatter.humanize: Format using .
    • PromConsole.NumberFormatter.humanizeNoSmallPrefix: For absolute valuesgreater than 1, format using using metric prefixes.For absolute values less than 1, format with 3 significant digits. This isuseful to avoid units such as milliqueries per second that can be produced byPromConsole.NumberFormatter.humanize.
    • PromConsole.NumberFormatter.humanize1024: Format the humanized result using a base of 1024 rather than 1000.