prometheus / prometheus

The Prometheus monitoring system and time series database.
https://prometheus.io/
Apache License 2.0
55.19k stars 9.08k forks source link

marathon unsupported protocol scheme or panic: runtime error: index out of range #1511

Closed samek closed 8 years ago

samek commented 8 years ago

Hi,

since we've have a large amount of tasks in marathon first thing I wanted to try with prometheus was getting data out of marathon.

our marathon version is 0.15.2.

config

global:
  scrape_interval:     5s
  evaluation_interval: 5s

scrape_configs:

- job_name: service-marathon
  marathon_sd_configs:
  - servers: 
    - "10.231.0.136:8080"
    - "10.231.0.137:8080"
    - "10.231.0.235:8080"

output

prometheus, version 0.17.0 (branch: release-0.17, revision: e11fab3)
  build user:       fabianreinartz@macpro
  build date:       20160302-17:47:15
  go version:       1.5.3
INFO[0000] Loading configuration file prometheus.yml     source=main.go:202
INFO[0000] Loading series map and head chunks...         source=storage.go:299
INFO[0000] 0 series loaded.                              source=storage.go:304
INFO[0000] Listening on :9090                            source=web.go:239
INFO[0000] Starting target manager...                    source=targetmanager.go:114
INFO[0000] Target manager started.                       source=targetmanager.go:168
WARN[0000] No AlertManager configured, not dispatching any alerts  source=notification.go:165
ERRO[0030] Error while updating services: Get 10.0.0.136:8080/v2/apps/?embed=apps.tasks: unsupported protocol scheme ""  source=marathon.go:66

I've tried adding http in-front of each host where marathon runs

global:
  scrape_interval:     5s
  evaluation_interval: 5s

scrape_configs:

- job_name: service-marathon
  marathon_sd_configs:
  - servers: 
    - "http://10.231.0.136:8080"
    - "http://10.231.0.137:8080"
    - "http://10.231.0.235:8080"

but the output is now

prometheus, version 0.17.0 (branch: release-0.17, revision: e11fab3)
  build user:       fabianreinartz@macpro
  build date:       20160302-17:47:15
  go version:       1.5.3
INFO[0000] Loading configuration file prometheus.yml     source=main.go:202
INFO[0000] Loading series map and head chunks...         source=storage.go:299
INFO[0000] 0 series loaded.                              source=storage.go:304
INFO[0000] Starting target manager...                    source=targetmanager.go:114
INFO[0000] Listening on :9090                            source=web.go:239
WARN[0000] No AlertManager configured, not dispatching any alerts  source=notification.go:165
panic: runtime error: index out of range

goroutine 215 [running]:
github.com/prometheus/prometheus/retrieval/discovery/marathon.targetForTask(0xc820e778d0, 0x0, 0x0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon/conversion.go:70 +0x1cf
github.com/prometheus/prometheus/retrieval/discovery/marathon.targetsForApp(0xc820e77b38, 0x0, 0x0, 0x0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon/conversion.go:60 +0x18b
github.com/prometheus/prometheus/retrieval/discovery/marathon.createTargetGroup(0xc820e77b38, 0xc8207163f0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon/conversion.go:36 +0x33
github.com/prometheus/prometheus/retrieval/discovery/marathon.AppsToTargetGroups(0xc82012e1a0, 0x30)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon/conversion.go:28 +0xdc
github.com/prometheus/prometheus/retrieval/discovery.(*MarathonDiscovery).fetchTargetGroups(0xc820010c00, 0x0, 0x0, 0x0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon.go:103 +0xb1
github.com/prometheus/prometheus/retrieval/discovery.(*MarathonDiscovery).Sources(0xc820010c00, 0x0, 0x0, 0x0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/discovery/marathon.go:46 +0x5b
github.com/prometheus/prometheus/retrieval.(*prefixedTargetProvider).Sources(0xc820010c40, 0x0, 0x0, 0x0)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/targetmanager.go:374 +0x66
github.com/prometheus/prometheus/retrieval.(*TargetManager).Run(0xc8201c0d70)
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/retrieval/targetmanager.go:125 +0x2c2
created by main.Main
    /Users/fabianreinartz/repos/src/github.com/prometheus/prometheus/cmd/prometheus/main.go:168 +0x138b

....

I've read that marathon is in beta for prometheus, which version is supposed to work ? Thanks.

fabxc commented 8 years ago

The code indicates that prepending the scheme was correct. What seems to be a problem is that the JSON returned from your marathon API doesn't specify any port for a task. Thus it panics.

The access to the port should be checked to not throw a panic of course. Generally, why does your task not specify a port. Is this expected behavior in the Marathon API? What would be a proper default port to chose?

fretboarder commented 8 years ago

I'm having the same problem with a Marathon instance that is accessible via https. A quick fix would be highly appreciated!

fabxc commented 8 years ago

The panic on missing port was fixed #1722 and is already in the latest release.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.