Skip to content

add infra cache count metric #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions unbound_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bufio"
"crypto/tls"
"crypto/x509"
"errors"
"flag"
"fmt"
"io"
Expand All @@ -25,11 +26,10 @@ import (
"net/url"
"os"
"regexp"
"sort"
"strconv"
"strings"

"sort"

"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -332,6 +332,12 @@ var (
prometheus.GaugeValue,
[]string{"buffer"},
"^mem\\.http\\.(\\w+)$"),
newUnboundMetric(
"infra_cache_count",
"Total number of infra cache entries",
prometheus.CounterValue,
nil,
"^infra\\.cache\\.count$"),
}
)

Expand Down Expand Up @@ -373,7 +379,6 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error {
for _, metric := range unboundMetrics {
if matches := metric.pattern.FindStringSubmatch(fields[0]); matches != nil {
value, err := strconv.ParseFloat(fields[1], 64)

if err != nil {
return err
}
Expand All @@ -393,7 +398,6 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error {
return err
}
value, err := strconv.ParseUint(fields[1], 10, 64)

if err != nil {
return err
}
Expand Down Expand Up @@ -486,7 +490,7 @@ func NewUnboundExporter(host string, ca string, cert string, key string) (*Unbou
}
roots := x509.NewCertPool()
if !roots.AppendCertsFromPEM(caData) {
return &UnboundExporter{}, fmt.Errorf("Failed to parse CA")
return &UnboundExporter{}, errors.New("Failed to parse CA")
}

/* Client authentication. */
Expand Down
Loading