-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- implement logrus for logging - renaming to pagerduty2es - general cleanup Signed-off-by: Markus Blaschke <[email protected]>
- Loading branch information
Showing
11 changed files
with
163 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/vendor/ | ||
/pagerduty-elasticsearch-exporter | ||
/pagerduty2es | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/vendor/ | ||
/pagerduty2elasticsearch-exporter | ||
/pagerduty2es | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
FROM golang:1.15 as build | ||
|
||
WORKDIR /go/src/github.com/webdevops/pagerduty2elasticsearch-exporter | ||
WORKDIR /go/src/github.com/webdevops/pagerduty2es | ||
|
||
# Get deps (cached) | ||
COPY ./go.mod /go/src/github.com/webdevops/pagerduty2elasticsearch-exporter | ||
COPY ./go.sum /go/src/github.com/webdevops/pagerduty2elasticsearch-exporter | ||
COPY ./Makefile /go/src/github.com/webdevops/alertmanager2es | ||
COPY ./go.mod /go/src/github.com/webdevops/pagerduty2es | ||
COPY ./go.sum /go/src/github.com/webdevops/pagerduty2es | ||
COPY ./Makefile /go/src/github.com/webdevops/pagerduty2es | ||
RUN make dependencies | ||
|
||
# Compile | ||
COPY ./ /go/src/github.com/webdevops/pagerduty2elasticsearch-exporter | ||
COPY ./ /go/src/github.com/webdevops/pagerduty2es | ||
RUN make lint | ||
RUN make build | ||
RUN ./pagerduty2elasticsearch-exporter --help | ||
RUN ./pagerduty2es --help | ||
|
||
############################################# | ||
# FINAL IMAGE | ||
############################################# | ||
FROM gcr.io/distroless/static | ||
COPY --from=build /go/src/github.com/webdevops/pagerduty2elasticsearch-exporter/pagerduty2elasticsearch-exporter / | ||
COPY --from=build /go/src/github.com/webdevops/pagerduty2es/pagerduty2es / | ||
USER 1000 | ||
ENTRYPOINT ["/pagerduty2elasticsearch-exporter"] | ||
ENTRYPOINT ["/pagerduty2es"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
log "github.com/sirupsen/logrus" | ||
"time" | ||
) | ||
|
||
type ( | ||
Opts struct { | ||
// logger | ||
Logger struct { | ||
Debug bool ` long:"debug" env:"DEBUG" description:"debug mode"` | ||
Verbose bool `short:"v" long:"verbose" env:"VERBOSE" description:"verbose mode"` | ||
LogJson bool ` long:"log.json" env:"LOG_JSON" description:"Switch log output to json format"` | ||
} | ||
|
||
// PagerDuty settings | ||
PagerDuty struct { | ||
AuthToken string `long:"pagerduty.authtoken" env:"PAGERDUTY_AUTH_TOKEN" description:"PagerDuty auth token" required:"true" json:"-"` | ||
Since time.Duration `long:"pagerduty.date-range" env:"PAGERDUTY_DATE_RANGE" description:"PagerDuty date range" default:"168h"` | ||
MaxConnections int `long:"pagerduty.max-connections" env:"PAGERDUTY_MAX_CONNECTIONS" description:"Maximum numbers of TCP connections to PagerDuty API (concurrency)" default:"4"` | ||
} | ||
|
||
// ElasticSearch settings | ||
Elasticsearch struct { | ||
Addresses []string `long:"elasticsearch.address" env:"ELASTICSEARCH_ADDRESS" delim:" " description:"ElasticSearch urls" required:"true"` | ||
Username string `long:"elasticsearch.username" env:"ELASTICSEARCH_USERNAME" description:"ElasticSearch username for HTTP Basic Authentication"` | ||
Password string `long:"elasticsearch.password" env:"ELASTICSEARCH_PASSWORD" description:"ElasticSearch password for HTTP Basic Authentication" json:"-"` | ||
ApiKey string `long:"elasticsearch.apikey" env:"ELASTICSEARCH_APIKEY" description:"ElasticSearch base64-encoded token for authorization; if set, overrides username and password" json:"-"` | ||
Index string `long:"elasticsearch.index" env:"ELASTICSEARCH_INDEX" description:"ElasticSearch index name (placeholders: %y for year, %m for month and %d for day)" default:"pagerduty"` | ||
BatchCount int `long:"elasticsearch.batch-count" env:"ELASTICSEARCH_BATCH_COUNT" description:"Number of documents which should be indexed in one request" default:"50"` | ||
RetryCount int `long:"elasticsearch.retry-count" env:"ELASTICSEARCH_RETRY_COUNT" description:"ElasticSearch request retry count" default:"5"` | ||
RetryDelay time.Duration `long:"elasticsearch.retry-delay" env:"ELASTICSEARCH_RETRY_DELAY" description:"ElasticSearch request delay for reach retry" default:"5s"` | ||
} | ||
|
||
// general options | ||
ServerBind string `long:"bind" env:"SERVER_BIND" description:"Server address" default:":8080"` | ||
ScrapeTime time.Duration `long:"scrape-time" env:"SCRAPE_TIME" description:"Scrape time (time.duration)" default:"5m"` | ||
} | ||
) | ||
|
||
func (o *Opts) GetJson() []byte { | ||
jsonBytes, err := json.Marshal(o) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
return jsonBytes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
module github.com/webdevops/pagerduty2elasticsearch-exporter | ||
module github.com/webdevops/pagerduty2es | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/PagerDuty/go-pagerduty v1.2.0 | ||
github.com/elastic/go-elasticsearch/v7 v7.8.0 | ||
github.com/google/logger v1.1.0 | ||
github.com/jessevdk/go-flags v1.4.0 | ||
github.com/prometheus/client_golang v1.7.0 | ||
github.com/sirupsen/logrus v1.6.0 | ||
golang.org/x/sys v0.0.0-20200620081246-981b61492c35 // indirect | ||
google.golang.org/protobuf v1.24.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.