Geomap with data containing 2 letter country codes remains empty

  • What Grafana version and what operating system are you using?
    Grafana v9.3.2 on openSUSE Leap 15.4
  • What are you trying to achieve?
    I’m trying to visualize login attempts per country on a GeoMap panel using two letter country codes.
  • How are you trying to achieve it?
    I have an InfluxDB with fail2ban data containing the number of hits as a value and the 2 letter country code that I got from the IP address as a tag.

    The query output actually shows data. The data selection also shows that there are 41 rows in the query output.

    I wanted to use the value as size of the marker but since I did not get anything shown on the map I set it to fixed.
  • What happened?
    An empty map is shown
  • What did you expect to happen?
    Show markers on the map at the locations of the countries.
  • Can you copy/paste the configuration(s) that you are having problems with?
    This is the dashboard JSON:
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 9,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "influxdb",
        "uid": "CKj-yZ2Vk"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "red",
            "mode": "fixed"
          },
          "custom": {
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 16,
        "w": 17,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "basemap": {
          "config": {
            "showLabels": true,
            "theme": "auto"
          },
          "name": "Layer 0",
          "opacity": 1,
          "tooltip": true,
          "type": "carto"
        },
        "controls": {
          "mouseWheelZoom": true,
          "showAttribution": true,
          "showDebug": false,
          "showMeasure": false,
          "showScale": false,
          "showZoom": true
        },
        "layers": [
          {
            "config": {
              "showLegend": false,
              "style": {
                "color": {
                  "fixed": "red"
                },
                "opacity": 1,
                "rotation": {
                  "fixed": 8,
                  "max": 360,
                  "min": -360,
                  "mode": "mod"
                },
                "size": {
                  "fixed": 5,
                  "max": 30,
                  "min": 1
                },
                "symbol": {
                  "fixed": "img/icons/marker/circle.svg",
                  "mode": "fixed"
                },
                "text": {
                  "field": "",
                  "fixed": "",
                  "mode": "fixed"
                },
                "textConfig": {
                  "fontSize": 12,
                  "offsetX": 0,
                  "offsetY": 0,
                  "textAlign": "center",
                  "textBaseline": "middle"
                }
              }
            },
            "filterData": {
              "id": "byRefId",
              "options": "A"
            },
            "location": {
              "gazetteer": "public/gazetteer/countries.json",
              "lookup": "country_code",
              "mode": "lookup"
            },
            "name": "Origin",
            "opacity": 0.7,
            "tooltip": true,
            "type": "markers"
          }
        ],
        "tooltip": {
          "mode": "details"
        },
        "view": {
          "allLayers": true,
          "id": "zero",
          "lastOnly": false,
          "lat": 0,
          "layer": "Hack origin",
          "lon": 0,
          "shared": false,
          "zoom": 2
        }
      },
      "pluginVersion": "9.3.2",
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "CKj-yZ2Vk"
          },
          "groupBy": [
            {
              "params": [
                "country_code"
              ],
              "type": "tag"
            }
          ],
          "hide": false,
          "measurement": "fail2ban",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "SELECT sum(\"failures\") FROM \"fail2ban\" WHERE $timeFilter GROUP BY \"country_code\"",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "table",
          "select": [
            [
              {
                "params": [
                  "failures"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "sum"
              }
            ]
          ],
          "tags": []
        }
      ],
      "title": "Login attempts per country",
      "transparent": true,
      "type": "geomap"
    }
  ],
  "refresh": "5m",
  "schemaVersion": 37,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-2d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Hack",
  "uid": "jck_9ZhVz",
  "version": 20,
  "weekStart": ""
}
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

  • Thanks in advance for your help.

Welcome

Could it be that your country code is 4 characters with the quote.

Can you replace the quotes via some function or regex and see what happens?

I had the value without quotes in the database. It was not recognized as a string and was therefore not selectable. I could see what happens if i replace the double quotes with single quotes…

It indeed works now. I don’t know why I could not select the country code data earlier.

1 Like