go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.25k stars 193 forks source link

Issue with prometheus with multiple maps #886

Closed nulu137 closed 1 year ago

nulu137 commented 1 year ago

I've run into an issue with prometheus if i have multiple maps defined in my config.toml . Tegola tries to register one metrics collector for every map defined. Can someone take a look at it or give me a hint how to configure prometheus with multiple maps inside one config.toml?

Actual Behavior

tegola_error.log

Expected Behavior

tegola starts up and exposes "/metrics" url

Steps to reproduce the issue.

Generate two maps from two different providers in your config.toml + prometheus observer:

Sanitized config.toml

`

[webserver]
port = ":3001"              

hostname = "localhost"
uri_prefix = "/mvt_basemap"

    [webserver.headers]
    Access-Control-Allow-Origin = "*"
    Access-Control-Allow-Methods = "GET, OPTIONS"

[observer]
type = "prometheus"

[[providers]]
name = "basemap_bac"                        
type = "mvt_postgis"                
host = "localhost"                  
port = 5432                         
database = "basemap_bac"                
...         

    [[providers.layers]]
    name = "water_polygons"    
    ...

[[maps]]
attribution = "OSM Contributers"
center = [53.3,-6.4, 7.0]
bounds = [-6.7394, 53.0545, -6.0178, 53.6024]

name = "basemap_bac"                             

    [[maps.layers]]
    name = "water_polygons"                         

[[providers]]
name = "basemap_vos"                        
type = "mvt_postgis"                
host = "localhost"                  
port = 5432                         
...             

    [[providers.layers]]
    name = "water_polygons"              
    ...

[[maps]]
attribution = "OSM Contributers"
 center = [52.3,7.8, 8.0]
 bounds = [6.9, 51.8, 8.7, 52.7]

name = "basemap_vos"                              

    [[maps.layers]]
    name = "water_polygons"                         

    provider_layer = "basemap_vos.water_polygons"  
    ...

`

ARolek commented 1 year ago

This is going to be a question for @gdey to look at as he did the implementation.

iwpnd commented 1 year ago

@gdey did you have time to take a look? I'd be happy to support with some direction from you.

gdey commented 1 year ago

I'm so sorry; I dropped the ball on this one. I've been traveling quite a bit since October, and with the holidays I totally forgot about this issue. I will make time to look at it today.

iwpnd commented 1 year ago

Hope your travels are not all that bad and you were able to get some good time off in between the years, @gdey :)

I took a look and addressed the issue by adding the provider name to the metric when there is more than one provider present - see my PR. I thought this is a sensible quick fix, as the alternative would mean a more significant refactor of the observability package. Wdyt @ARolek and @gdey?