ExpressenAB / bigip_exporter

Prometheus exporter for BIG-IP metrics
MIT License
90 stars 39 forks source link

panic: runtime error: index out of range #15

Open mgusek opened 7 years ago

mgusek commented 7 years ago

Hi, i'm running exporter in debug mode in foreground. My BigIP has Version BIG-IP 11.6.0 Build 5.0.429 Hotfix HF5. After a while, i'm getting this error:


17:42:57 DEBUG node_collector.go:204 Successfully fetched statistics for nodes 17:42:57 DEBUG node_collector.go:211 Getting node statistics took 585.037792ms 17:42:57 DEBUG pool_collector.go:372 Successfully fetched statistics for pools 17:42:57 DEBUG pool_collector.go:379 Getting pool statistics took 870.630355ms 17:42:58 DEBUG vs_collector.go:504 Successfully fetched statistics for virtual servers 17:42:58 DEBUG vs_collector.go:511 Getting virtual server statistics took 2.202604024s 17:42:58 DEBUG rule_collector.go:167 Successfully fetched statistics for rules 17:42:58 DEBUG rule_collector.go:174 Getting rule stats took 2.259964622s 17:42:58 DEBUG bigip_collector.go:61 Total collection time was: 2.260005406s 17:43:58 DEBUG vs_collector.go:504 Successfully fetched statistics for virtual servers 17:43:58 DEBUG vs_collector.go:511 Getting virtual server statistics took 1.680180309s 17:43:58 DEBUG node_collector.go:204 Successfully fetched statistics for nodes 17:43:58 DEBUG node_collector.go:211 Getting node statistics took 1.725774764s panic: runtime error: index out of range

goroutine 8306 [running]: panic(0x858c00, 0xc4200100d0) /usr/local/go/src/runtime/panic.go:500 +0x1a1 github.com/ExpressenAB/bigip_exporter/collector.(RuleCollector).Collect(0xc42005cf40, 0xc4207ce1e0) /Users/christoffer.gunning/golang/src/github.com/ExpressenAB/bigip_exporter/collector/rule_collector.go:155 +0x812 github.com/ExpressenAB/bigip_exporter/collector.(BigipCollector).Collect.func1(0xc4207ce1e0, 0xc42049c1e0, 0xafd0e0, 0xc42005cf40) /Users/christoffer.gunning/golang/src/github.com/ExpressenAB/bigip_exporter/collector/bigip_collector.go:53 +0x3b created by github.com/ExpressenAB/bigip_exporter/collector.(*BigipCollector).Collect /Users/christoffer.gunning/golang/src/github.com/ExpressenAB/bigip_exporter/collector/bigip_collector.go:55 +0x141

How can i help to solve this ?

Michael

cgunning commented 7 years ago

Hi, Michael!

Thanks for your issue. I have been home sick these last couple of days so I apologize for the late reply. This seems to be similar to a previous issue. I will get back to you with more information regarding identifying the issue and I'd be really grateful if you'd be able to help.

Best regards, Christoffer Gunning

cgunning commented 7 years ago

The problem seems to be that usually there are events for iRules such as HTTP_REQUEST or HTTP_RESPONSE.

The error is in the following code:

keyParts := strings.Split(key, "/")
path := keyParts[len(keyParts)-2]
pathParts := strings.Split(path, "~")
partition := pathParts[1]
eventParts := strings.Split(pathParts[len(pathParts)-1], ":")
ruleName := eventParts[0]
event := eventParts[1]

And it assumes that the structure of the response is <partition>~<rule-name>:<event>

It seems that because it fails for you, you do not have those events

cgunning commented 7 years ago

Here's an example for how my output looks. Are you able to provide me with an example of an output from what you get? The relevant part in this issue is the first line. "https://localhost/mgmt/tm/ltm/rule/~<partition>~<rule-name>/~<partition>~<rule-name>:<event>/stats". From what I can guess, you do not have the :<event> part.

    "https://localhost/mgmt/tm/ltm/rule/~<partition>~<rule-name>/~<partition>~<rule-name>:<event>/stats": {
      "nestedStats": {
        "kind": "tm:ltm:rule:rulestats",
        "selfLink": "https://localhost/mgmt/tm/ltm/rule/~<partition>~<rule-name>:<event>/stats?ver=12.1.1",
        "entries": {
          "aborts": {
            "value": 0
          },
          "avgCycles": {
            "value": 261253
          },
          "eventType": {
            "description": "HTTP_REQUEST"
          },
          "failures": {
            "value": 78
          },
          "maxCycles": {
            "value": 4421906
          },
          "minCycles": {
            "value": 9906
          },
          "tmName": {
            "description": "/<partition>/<rule-name>"
          },
          "priority": {
            "value": 100
          },
          "totalExecutions": {
            "value": 88051028
          }
        }
      }
    }
mgusek commented 7 years ago

Hello Christopher, running https://localhost/mgmt/tm/ltm/rule/~Common~/stats i get stats:

{ "kind":"tm:ltm:rule:rulestats", "generation":1, "selfLink":"https://localhost/mgmt/tm/ltm/rule/~Common~/stats?ver=11.6.0", "entries":{
"aborts":{
"value":0 }, "avgCycles":{
"value":0 }, "eventType":{
"description":"HTTP_REQUEST" }, "failures":{
"value":0 }, "maxCycles":{
"value":0 }, "minCycles":{
"value":0 }, "tmName":{
"description":"/Common/" }, "priority":{
"value":500 }, "totalExecutions":{
"value":0 } } } (sorry for non indent) As you can see, where is no ':' in my request. Hope it helps.

Michael

cgunning commented 7 years ago

Thanks for the information.

Hmm. Alright. eventType is in the json as well so perhaps I'll have to take that instead. Just to be fully clear. Do you get the same kind of answer when you run against /mgmt/tm/ltm/rule/stats? (without the :).

mgusek commented 7 years ago

Yes, I'm used https:///mgmt/tm/ltm/rule/~Common~/stats for example above.