|
|
|
@ -2,6 +2,7 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"flag" |
|
|
|
"flag" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
|
@ -135,7 +136,7 @@ func (s *appScraper) stats() (*AppStats, error) { |
|
|
|
// validate returned json is complete
|
|
|
|
// validate returned json is complete
|
|
|
|
// requestCounter and requestRates should be empty maps, so we are fine here
|
|
|
|
// requestCounter and requestRates should be empty maps, so we are fine here
|
|
|
|
if stats.Duration == nil { |
|
|
|
if stats.Duration == nil { |
|
|
|
return nil, fmt.Errorf("Invalid JSON returned, could not retreive duration.*") |
|
|
|
return nil, errors.New("Invalid JSON returned, could not retrieve duration") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return &stats, err |
|
|
|
return &stats, err |
|
|
|
@ -157,6 +158,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Collect implements prometheus.Describe.Collect
|
|
|
|
func (e *Exporter) Collect(ch chan<- prometheus.Metric) { |
|
|
|
func (e *Exporter) Collect(ch chan<- prometheus.Metric) { |
|
|
|
|
|
|
|
|
|
|
|
stats, err := e.scraper.stats() |
|
|
|
stats, err := e.scraper.stats() |
|
|
|
@ -205,6 +207,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewExporter creates a new prometheus exporter and app scraper
|
|
|
|
func NewExporter(endpoint string) (*Exporter, error) { |
|
|
|
func NewExporter(endpoint string) (*Exporter, error) { |
|
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(endpoint, "://") { |
|
|
|
if !strings.Contains(endpoint, "://") { |
|
|
|
|