Skip to content

Commit

Permalink
Merge pull request #53 from sensu/asachs01-patch-1
Browse files Browse the repository at this point in the history
Updates to readme
  • Loading branch information
amdprophet authored Nov 23, 2022
2 parents 4ef9132 + 435cb37 commit 2024a9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Check out [The Sensu Blog][5] or [Sensu Docs][6] for a step by step guide!
```
Usage:
sensu-influxdb-handler [flags]
sensu-influxdb-handler [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version number of this plugin
Flags:
-a, --addr string the url of the influxdb server, should be of the form 'http://host:port/dbname', defaults to 'http://localhost:8086' or value of INFLUXDB_ADDR env variable (default "http://localhost:8086")
Expand All @@ -54,6 +60,7 @@ Flags:
-t, --token string the authentication token needed for influxdbv2, use '<user>:<password>' as token for influxdb 1.8 compatibility
-u, --username string (Deprecated) the username for the given db, Transition to influxdb v1.8 compatible authentication token
Use "sensu-influxdb-handler [command] --help" for more information about a command.
```

### Environment variables
Expand Down Expand Up @@ -156,8 +163,8 @@ spec:
timeout: 10
env_vars:
- INFLUXDB_ADDR=http://influxdb.default.svc.cluster.local:8086
- INFLUXDB_TOKEN="xxxx-xxxxx-xxxx-xxxx-xxxxx"
- INFLUXDB_BUCKET="some_bucket"
- INFLUXDB_TOKEN=xxxx-xxxxx-xxxx-xxxx-xxxxx
- INFLUXDB_BUCKET=some_bucket
- INFLUXDB_ORG="some_org"
filters:
- has_metrics
Expand All @@ -180,8 +187,8 @@ spec:
timeout: 10
env_vars:
- INFLUXDB_ADDR=http://influxdb.default.svc.cluster.local:8086
- INFLUXDB_TOKEN="username:password"
- INFLUXDB_BUCKET="database"
- INFLUXDB_TOKEN=username:password
- INFLUXDB_BUCKET=database
filters:
- has_metrics
runtime_assets:
Expand Down
12 changes: 6 additions & 6 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand All @@ -23,7 +23,7 @@ func TestStatusMetrics(t *testing.T) {
event.Metrics = nil

var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
expectedBody := `check1,sensu_entity_name=entity1 status=0`
assert.Contains(string(body), expectedBody)
w.WriteHeader(http.StatusOK)
Expand All @@ -47,7 +47,7 @@ func TestSendMetrics(t *testing.T) {
event.Metrics = corev2.FixtureMetrics()

var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
expectedBody := `answer,foo=bar,sensu_entity_name=entity1 value=42`
assert.Contains(string(body), expectedBody)
w.WriteHeader(http.StatusOK)
Expand All @@ -67,7 +67,7 @@ func TestSendMetricsWithToken(t *testing.T) {
event.Metrics = corev2.FixtureMetrics()

var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
header := r.Header
assert.Contains(header["Authorization"][0], config.Token)
expectedBody := `answer,foo=bar,sensu_entity_name=entity1 value=42`
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestSendMetricsHostStripping(t *testing.T) {
event.Metrics.Points[0].Name = tt.metricName + ".answer"

var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
assert.Contains(string(body), tt.expectedBody)
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte(`{"ok": true}`))
Expand All @@ -173,7 +173,7 @@ func TestSendAnnotation(t *testing.T) {
event.Metrics = corev2.FixtureMetrics()

var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
expectedBody := `sensu_event,check=check1,entity=entity1 description="\"ALERT - entity1/check1 : FAILURE\"",occurrences=1i,status=1i,title="\"Sensu Event\""`
assert.Contains(string(body), expectedBody)
w.WriteHeader(http.StatusOK)
Expand Down

0 comments on commit 2024a9a

Please sign in to comment.