You can then choose which column to group the results by. To group the results by column, flip the group switch at the top of the editor. To add more columns to filter on use the plus button. Using the first dropdown, select if all the filters need to match (AND) or if only one of the filters needs to match (OR). To add a filter, flip the switch at the top of the editor. You can also specify an optional aggregation function.Īdd further value columns by clicking the plus button and another column dropdown appears. Using the dropdown, select a column to include in the data. Columns and Aggregation functions (SELECT) When the dataset is selected, the table dropdown is populated with the tables that are available. The dropdown is be populated with the databases that the user has access to. In the dataset dropdown, choose the MySQL database to query. For example a table name like table-name will be quoted with backticks `table-name`. Note: If your table or database name contains a reserved word or a not permitted character the editor will put quotes around them. To use the time series format one of the columns must be named time. The response from MySQL can be formatted as either a table or as a time series. You can run the built query by pressing the Run query button in the top right corner of the editor. This topic explains querying specific to the MySQL data source.įor general documentation on querying data sources in Grafana, see Query and transform data. The MySQL query builder is available when editing a panel using a MySQL data source. Provisioning examples Basic Provisioning apiVersion: 1 You can define and configure the data source in YAML files as part of Grafana’s provisioning system.įor more information about provisioning, and for available configuration options, refer to Provisioning Grafana. You can use wildcards ( *) in place of database or table if you want to grant access to more databases and tables. GRANT SELECT ON mydatabase.mytable TO 'grafanaReader' To protect against this we Highly recommend you create a specific mysql user with restricted permissions.Įxample: CREATE USER 'grafanaReader' IDENTIFIED BY 'password' For example, statements like USE otherdb and DROP TABLE user would beĮxecuted. The queryĬould include any SQL statement. Grafana does not validate that the query is safe. The specified database and tables you want to query. The database user you specify when you add the data source should only be granted SELECT permissions on You can also override this setting in a dashboard panel under its data source options. We recommend setting this value to match your MySQL write frequency.įor example, use 1m if MySQL writes data every minute. This value must be formatted as a number followed by a valid time identifier: Identifier The Min time interval setting defines a lower limit for the $_interval and $_interval_ms variables. This should always be lower than configured wait_timeout in MySQL (Grafana v5.4+). The maximum amount of time in seconds a connection may be reused, default 14400/4 hours. If set will set the maximum number of idle connections to the number of maximum open connections (Grafana v9.5.1+). The maximum number of connections in the idle connection pool, default 100 (Grafana v5.4+). The maximum number of open connections to the database, default 100 (Grafana v5.4+). For more information, refer to the MySQL documentation. If you leave this field empty, then the time zone is not updated. Set the value used in the session with SET time_zone='.'. This is necessary, if the timezone of the database (or the host of the database) is set to something other than UTC. Specify the time zone used in the database session, such as Europe/Berlin or +02:00. The IP address/hostname and optional port of your MySQL instance. This is how you refer to the data source in panels and queries.ĭefault data source means that it will be pre-selected for new panels. Set the data source’s basic configuration options. The Settings tab of the data source is displayed. Under Your connections, click Data sources. To access the data source configuration page: Only users with the organization administrator role can add data sources.Īdministrators can also configure the data source via YAML with Grafana’s provisioning system. Grafana ships with a built-in MySQL data source plugin that allows you to query and visualize data from a MySQL compatible database.įor instructions on how to add a data source to Grafana, refer to the administration documentation. Usage of time_sec will eventually be deprecated. Starting from Grafana v5.1 you can name the time column time in addition to earlier supported time_sec. Grafana Cloud Enterprise Open source MySQL data source
0 Comments
Leave a Reply. |