-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ContaAzul/init
Initial structure
- Loading branch information
Showing
6 changed files
with
125 additions
and
9 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,14 +1,9 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
# Output of the go coverage tool | ||
*.out | ||
|
||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | ||
.glide/ | ||
# Project specific | ||
vendor | ||
newrelic_exporter |
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,5 @@ | ||
FROM scratch | ||
EXPOSE 9112 | ||
WORKDIR / | ||
COPY newrelic_exporter . | ||
ENTRYPOINT ["./newrelic_exporter"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
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,2 +1,22 @@ | ||
# newrelic_exporter | ||
|
||
Exports New Relic applications metrics data as prometheus metrics. | ||
|
||
### Running | ||
|
||
```console | ||
./newrelic_exporter --api-key=${NEWRELIC_API_KEY} | ||
``` | ||
|
||
Or with docker: | ||
|
||
```console | ||
docker run -p 9112:9112 -e "NEWRELIC_API_KEY=${NEWRELIC_API_KEY}" caninjas/newrelic_exporter | ||
``` | ||
|
||
### Flags | ||
|
||
Name | Description | ||
--------|--------------------------------------------- | ||
addr | Address to bind the server (default :9112) | ||
api-key | Your New Relic API key (required) |
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,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/prometheus/common/log" | ||
"gopkg.in/alecthomas/kingpin.v2" | ||
) | ||
|
||
var ( | ||
version = "dev" | ||
addr = kingpin.Flag("addr", "Address to bind the server").Default(":9112").OverrideDefaultFromEnvar("SERVER_ADDR").String() | ||
apiKey = kingpin.Flag("api-key", "New Relic API key").OverrideDefaultFromEnvar("NEWRELIC_API_KEY").String() | ||
) | ||
|
||
func main() { | ||
kingpin.Version(version) | ||
kingpin.HelpFlag.Short('h') | ||
kingpin.Parse() | ||
|
||
log.Info("Starting newrelic_exporter ", version) | ||
|
||
if *apiKey == "" { | ||
log.Fatal("You must provide your New Relic API key") | ||
} | ||
|
||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, | ||
` | ||
<html> | ||
<head><title>NewRelic Exporter</title></head> | ||
<body> | ||
<h1>NewRelic Exporter</h1> | ||
<p><a href="/metrics">Metrics</a></p> | ||
</body> | ||
</html> | ||
`) | ||
}) | ||
|
||
log.Infof("Server listening on %s", *addr) | ||
if err := http.ListenAndServe(*addr, nil); err != nil { | ||
log.Fatalf("Error starting server: %s", err) | ||
} | ||
} |