new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Grafana dashboards · all subjects

data-source/mysql

30 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

MySQL query editor access locations

The MySQL query editor is located on the Explore page. You can also access it from a dashboard panel by clicking the ellipsis in the upper right of the panel and selecting Edit.

MySQL query editor modes

The MySQL query editor has two modes: Builder and Code. Builder mode helps you build a query using a visual interface. Code mode allows for advanced querying and offers support for complex SQL query writing.

MySQL Builder mode components

The MySQL Builder mode includes: Format (select Table or Time series response format, default is Table), Dataset (select database, then table from that database), Data operations (optional aggregations that can be added with + sign), Column (select column for aggregation), Alias (optional, can be typed or selected), Filter (toggle to add filter by column value with AND/OR operators and optional $__timeFilter macro), Group (toggle to add Group by column, multiple columns supported), Order (toggle to add ORDER BY with ASC/DESC and optional limit, default limit is 50), and Preview (toggle for SQL preview, toggled on by default).

MySQL Code mode features

Code mode supports auto-completion of tables, columns, SQL keywords, standard SQL functions, Grafana template variables, and Grafana macros. Columns cannot be completed before a table has been specified. Click the {} in the bottom right to format the query. Click the downward caret to expand the Code mode editor. CTRL/CMD + Return executes the query.

MySQL Code mode changes are not transferable to Builder mode

Changes made to a query in Code mode will not transfer to Builder mode and will be discarded. You will be prompted to copy your code to the clipboard to save any changes.

MySQL reserved words and prohibited characters in names

If a table or database name contains a reserved word or a prohibited character, the editor will put quotes around the name. For example, the name `table-name` will be quoted with backticks as `` `table-name` ``.

MySQL default database configuration restriction

If a default database is configured in the Data Source Configuration page or via a provisioning configuration file, users will be restricted to querying only that pre-configured database.

MySQL macro $__timeEpoch(dateColumn)

Replaces the value with an expression to convert to a UNIX Epoch timestamp and renames the column to `time_sec`. Example: UNIX_TIMESTAMP(dateColumn) AS time_sec.

MySQL macro $__timeFilter(dateColumn)

Applies a time range filter using the specified column name and fetches only the data that falls within that range. Example: dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983).

MySQL macro $__timeFrom()

Replaces the value with the start of the currently active time selection. Example: FROM_UNIXTIME(1494410783).

MySQL macro $__timeTo()

Replaces the value with the end of the currently active time selection. Example: FROM_UNIXTIME(1494410983).

MySQL macro $__timeGroup(dateColumn,'5m')

Replaces the value with an expression suitable for use in a GROUP BY clause and creates bucket timestamps at a fixed interval. Example: cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed).

MySQL macro $__timeGroup(dateColumn,'5m', 0)

Same as the $__timeGroup(dateColumn,'5m') macro, but includes a fill parameter to ensure missing points in the series are added by Grafana, using 0 as the default value. This applies only to time series queries.

MySQL macro $__timeGroup(dateColumn,'5m', NULL)

Same as the $__timeGroup(dateColumn,'5m', 0) macro, but NULL is used as the value for missing points. This applies only to time series queries.

MySQL macro $__timeGroup(dateColumn,'5m', previous)

Same as the $__timeGroup(dateColumn,'5m') macro, but uses the previous value in the series as the fill value. If no previous value exists, NULL will be used. This applies only to time series queries.

MySQL macro $__timeGroupAlias(dateColumn,'5m')

Replaces the value identical to $__timeGroup but with an added column alias.

MySQL macro $__unixEpochFilter(dateColumn)

Replaces the value by a time range filter using the specified column name with times represented as a UNIX timestamp. Example: dateColumn > 1494410783 AND dateColumn < 1494497183.

MySQL macro $__unixEpochFrom()

Replaces the value with the start of the currently active time selection as a UNIX timestamp. Example: 1494410783.

MySQL macro $__unixEpochTo()

Replaces the value with the end of the currently active time selection as UNIX timestamp. Example: 1494497183.

MySQL macro $__unixEpochNanoFilter(dateColumn)

Replaces the value with a time range filter using the specified column name with time represented as a nanosecond timestamp. Example: dateColumn > 1494410783152415214 AND dateColumn < 1494497183142514872.

MySQL macro $__unixEpochNanoTo()

Replaces the value with the end of the currently active time selection as nanosecond timestamp. Example: 1494497183142514872.

MySQL macro $__unixEpochGroup(dateColumn,'5m', [fillmode])

Same as $__timeGroup but for times stored as Unix timestamp. Note that fillMode only works with time series queries.

MySQL macro $__unixEpochGroupAlias(dateColumn,'5m', [fillmode])

Same as $__timeGroup but also adds a column alias. Note that fillMode only works with time series queries.

MySQL fill resampling safeguards in Grafana 13.0

As of Grafana 13.0, fill resampling in $__timeGroup and $__unixEpochGroup includes additional safeguards to prevent incorrect data points when the query returns no rows or the time range falls outside the data boundaries.

MySQL Table format queries

If the Format option is set to Table, you can execute virtually any type of SQL query. The Table panel will automatically display the resulting columns and rows from your query. You can change or customize the name of a Table panel column by using the SQL keyword AS syntax.

MySQL Time series format requirements

To run a time series query you must include a column named `time` that returns either a SQL datetime value or a numeric datatype representing the UNIX epoch time in seconds. Additionally, the query results must be sorted by the `time` column for proper visualization in panels.

MySQL Time series backward compatibility with metric column

For backward compatibility, an exception applies to queries returning three columns, including a string column named `metric`. Instead of converting the metric column into field labels, it is used as the field name, and the series name is set to the value of the metric column.

MySQL template variables

Instead of hard-coding values like server, application, or sensor names in your metric queries, you can use variables. Variables appear as drop-down select boxes at the top of the dashboard, making it easy to change the data displayed in your dashboard.

MySQL annotations support

Annotations allow you to overlay event information on your graphs, helping you correlate events with metrics. You can write SQL queries that return event data to display as annotations on your dashboards.

MySQL alerting with time series queries

You can use time series queries to create Grafana-managed alert rules. Table formatted queries are not supported in alert rule conditions.

Give your agent this brain