世界Map面板grafana

2vuwiymt  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(417)

我的数据:

New York    10
Paris        8
Mumbai      15
Tokya        7
Sydney       8
London      11

我将如何使用grafana中的worldmap面板绘制上述数据。我想显示对应于那个位置的值。

c9x0cxw0

c9x0cxw01#

请参见:

CREATE TABLE `worldmap` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `country_code` varchar(3) NOT NULL,
      `value` INT NOT NULL,
      `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
    and with data like this:

    INSERT INTO `testdata`.`worldmap`
    (`country_code`,
    `value`,
    `timestamp`)
    VALUES
    ('IE',
    3.0,
    now());
    and this query (although it is probably better to do a GROUP BY and sum here rather than using Grafana’s aggregation):

    SELECT
      UNIX_TIMESTAMP(`timestamp`) as time_sec,
      `value` as value,
      country_code as metric
    FROM worldmap
    WHERE $__timeFilter(`timestamp`)
    ORDER BY `timestamp` ASC

相关问题