Skip to content
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

use the correct metric for errors #15

Merged
merged 7 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
coverage.out

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Running locally:

1. Docker Desktop (with kubernetes)
2. skaffold https://skaffold.dev/docs/install/
3. `skaffold dev`
3. `skaffold dev -p local`
4. `kubectl -n kubelet-summary-exporter port-forward ds/kubelet-summary-exporter 9091`
5. `curl localhost:9091/metrics`

Expand Down
8 changes: 4 additions & 4 deletions pkg/scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) {
if err != nil {
s.errCnt++
ch <- prometheus.MustNewConstMetric(
s.storage,
s.errors,
prometheus.CounterValue,
s.errCnt,
"request error",
Expand All @@ -85,7 +85,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) {
if resp.StatusCode != http.StatusOK {
s.errCnt++
ch <- prometheus.MustNewConstMetric(
s.storage,
s.errors,
prometheus.CounterValue,
s.errCnt,
"status error",
Expand All @@ -99,7 +99,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) {
if err != nil {
s.errCnt++
ch <- prometheus.MustNewConstMetric(
s.storage,
s.errors,
prometheus.CounterValue,
s.errCnt,
"read body error",
Expand All @@ -111,7 +111,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) {
summary, err := s.parse(body)
if err != nil {
ch <- prometheus.MustNewConstMetric(
s.storage,
s.errors,
prometheus.CounterValue,
s.errCnt,
"parse body error",
Expand Down
1 change: 0 additions & 1 deletion pkg/scraper/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func TestDecodingJson(t *testing.T) {
if diff := cmp.Diff(tc.WantSummary, summary); diff != "" {
t.Errorf("summary mismatch (-want +got):\n%s", diff)
}

})
}
}
4 changes: 2 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"time"

"go.uber.org/zap"
Expand All @@ -19,7 +19,7 @@ import (

func ConfigureTLS(logger *zap.Logger, certAuthorityFile string, insecure bool, nodeHost string) error {
// Set the root CA pool
cadata, err := ioutil.ReadFile(certAuthorityFile)
cadata, err := os.ReadFile(certAuthorityFile)
if err != nil {
return err
}
Expand Down
23 changes: 14 additions & 9 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
apiVersion: skaffold/v2beta19
apiVersion: skaffold/v4beta6
kind: Config
metadata:
name: kubelet-summary-exporter
build:
artifacts:
- image: kubelet-summary-exporter/exporter
context: ./
docker:
dockerfile: Dockerfile
tagPolicy:
inputDigest: {}
deploy:
- image: kubelet-summary-exporter/exporter
docker:
dockerfile: Dockerfile
manifests:
kustomize:
paths:
- config/local
- config/base
profiles:
- name: local
manifests:
kustomize:
paths:
- config/local
Loading