世界地图面板Grafana

时间:2018-10-23 10:30:59

标签: mysql sql grafana

我的数据:

enter image description here

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

如何使用grafana中的WorldMap Panel绘制以上数据。 我想显示与该位置对应的值。

1 个答案:

答案 0 :(得分:0)

请参阅:

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

相关问题