Out of the box, Kibana includes the ability to display geo-data on maps provided by Elastic’s tile service. This provides a great introduction to what Kibana can do, but the maximum zoom level is limited if you don’t have an X-Pack license. For example, the maximum zoom for ObjectRocket’s home base of Austin, Texas is below:
The good news is that it’s easy enough to configure Kibana to use another tile service or WMS compliant mapping server.
Why Use a Different Mapping Service?
The Elastic tile service is a great benefit to all users, but there may be times you want to diverge from the default service. Here are a few:
- You want to zoom further to street-level data
- You want to add new layers or provide a different map style
- You want a fully custom map, like the inside of a building, for example
What these all boil down to is finding a server that provides the data you want and then configuring Kibana to use that server.
Unfortunately, Kibana can cause a bit of confusion because it can leverage two completely different types of map services. I’ll introduce those before we jump into how to use them. By default, Kibana draws maps from a Tile Map Service, or TMS. Tile services chop up maps into square tiles that can be accessed by their coordinates and zoom level. This is what Elastic provides with their service and this is configured globally in the kibana.yml
configuration file. An alternate way to display maps in Kibana is to use a WMS-compliant Map Service, or WMS. A web map service operates using a different protocol and generates maps from data in a GIS database. This can be set from within the Kibana UI.
Using Third Party Map Services
There are a number of commercial map services out there, as well as free data sources for creating maps like OpenStreetMap. For testing purposes, there are free tile services based on OpenStreetMap, like Stamen, that you can test with. On the WMS side, there are also some free map servers for testing, like the National Map in the US. Finally, there are options for setting up your own mapping service, which I’ll cover later.
Setting up Kibana to use a different tile service
Once again, by default mapping for Kibana is based off of a tile service. Stamen, which is mentioned above, is one of my favorite free to test services and offers a number of sharp map styles, so we’ll test with that.
You’ll need access to your kibana.yml
file to make this change, so if you’re on a hosted service, like ObjectRocket for Elasticsearch, you can use a local kibana install to test it out first. Once you’ve located the kibana.yml
file, you’ll add the following entries:
tilemap.url: "https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg"
tilemap.options.maxZoom: 20
tilemap.options.attribution: 'Map tiles by [Stamen Design](http://stamen.com), under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0). Data by [OpenStreetMap](http://openstreetmap.org), under ODbL(http://www.openstreetmap.org/copyright).'
The first setting is the url for the tile service and follows the usual endpoint/{z}/{x}/{y}.jpg/png
format that standard tile services use. Note that Stamen has a number of cool styles, like ‘toner’ and ‘watercolor’, that you can use by replacing ‘terrain’ in the url. The second setting is the maximum number of zoom settings. Some services don’t advertise this, so it will just require a little trial and error. Finally, and very importantly is properly attributing the maps to the creator. The attribution markdown will be displayed in the lower right corner of the map visualization.
Once that’s set and you restart Kibana, you’ll now see that you can zoom a lot further and get some pretty cool stylized maps. Compare the picture below to the one above:
Connecting to a WMS Map from Kibana
The configuration is a little different for a WMS map and must be set within Kibana itself, rather than from the configuration file. For this example, I’ll use the United States Geological Services’ Nationalmap, specifically transportation maps so we can play with the different layers available. First, you’ll need to load up a coordinate map visualization in Kibana and then click the “options” button. From there, you’re going to select “WMS compliant map server.”
Once you select that, a bunch of new settings will display. You’ll need to fill in the URL for the WMS server, which layers to use, which version of the WMS standard the server is running, image type to load, and what styles to use. These settings are described in the Kibana documentation.
This is a bit more complicated than the tile service which just takes a few coordinates, but luckily the map service we’ll use has some tools built in. First of all, if you go to the Nationalmap page, it will give you a nice description page of the map and its features. This page describes the map and all of its layers. If you want more details about the maps capabilities, click on the little WMS
link at the top, and you’ll see some detailed XML of the server’s capabilities, like version, image formats supported and more. Based on this information and the WMS link, we’ll use the following settings for this map:
- WMS url: https://services.nationalmap.gov/arcgis/services/transportation/MapServer/WMSServer
- WMS layers:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36
- WMS version: 1.3.0
- WMS format: image/png
- WMS attribution: Provided by the United States Geological Service (Nationalmap.gov)
- Styles: blank
One note about the layers. It looks like the map we’re using has a hierarchy of layers, but there’s no shorthand I can find for calling all of them out so just list out the individual layers.
If you have that all set up, you should now be able to see a view like this:
The WMS settings can also be set as a default for all visualizations in the Kibana Advanced Settings screen.
Setting Up Your Own Map or Tile Server
On a final note, once you want to take this into production, running your own tile/map server may be the way to go. You can do fully custom maps, like an NHL rink, or create street maps or topographical maps from something like OpenStreetMap and apply your own layers. There are great open source tools like geoserver, which is mentioned in the Elastic blog, or TileCache that all provide tutorials and detailed docs on how to get started. Also, OpenStreepMap provides tons of information in their wiki to help you get started along with the site SWITCH2OSM that provides resources to get started on serving OpenStreetMap data.
Interested in what Elasticsearch can do for your app? We offer fully managed and hosted Elasticsearch instances complete with DBA experts that can help you get the most from Elasticsearch and Kibana without tying up your development resources. Contact us for a consultation.