-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82853df
commit 8993a18
Showing
13 changed files
with
404 additions
and
111 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- main | ||
|
||
env: | ||
GOVERSION: "1.16" | ||
GOVERSION: "1.17" | ||
|
||
jobs: | ||
lint: | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- main | ||
|
||
env: | ||
GOVERSION: "1.16" | ||
GOVERSION: "1.17" | ||
|
||
jobs: | ||
lint: | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- "*" | ||
|
||
env: | ||
GOVERSION: "1.16" | ||
GOVERSION: "1.17" | ||
|
||
jobs: | ||
release: | ||
|
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 |
---|---|---|
|
@@ -3,9 +3,9 @@ FROM alpine | |
LABEL maintainer="Axiom, Inc. <[email protected]>" | ||
|
||
# Upgrade packages and install ca-certificates. | ||
RUN apk update --no-cache | ||
RUN apk upgrade --no-cache | ||
RUN apk add --no-cache ca-certificates | ||
RUN apk update --no-cache \ | ||
&& apk upgrade --no-cache \ | ||
&& apk add --no-cache ca-certificates | ||
|
||
# Copy binary into image. | ||
COPY axiom-syslog-proxy /usr/bin/axiom-syslog-proxy | ||
|
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 |
---|---|---|
@@ -1,52 +1,79 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"log" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/axiomhq/axiom-go/axiom" | ||
"github.com/axiomhq/pkg/version" | ||
|
||
"github.com/axiomhq/axiom-syslog-proxy/server" | ||
) | ||
|
||
var ( | ||
deploymentURL = os.Getenv("AXIOM_URL") | ||
ingestToken = os.Getenv("AXIOM_TOKEN") | ||
ingestDataset = os.Getenv("AXIOM_DATASET") | ||
const ( | ||
exitOK int = iota | ||
exitConfig | ||
exitInternal | ||
) | ||
|
||
var ( | ||
addrTCP = flag.String("addr-tcp", ":601", "Listen address <ip>:<port>") | ||
addrUDP = flag.String("addr-udp", ":514", "Listen address <ip>:<port>") | ||
) | ||
|
||
func main() { | ||
os.Exit(Main()) | ||
} | ||
|
||
func Main() int { | ||
// Export `AXIOM_TOKEN` and `AXIOM_ORG_ID` for Axiom Cloud | ||
// Export `AXIOM_URL` and `AXIOM_TOKEN` for Axiom Selfhost | ||
|
||
log.Print("starting axiom-syslog-proxy version ", version.Release()) | ||
|
||
flag.Parse() | ||
|
||
if deploymentURL == "" { | ||
deploymentURL = axiom.CloudURL | ||
} | ||
if ingestToken == "" { | ||
log.Fatal("missing AXIOM_TOKEN") | ||
ctx, cancel := signal.NotifyContext(context.Background(), | ||
os.Interrupt, | ||
os.Kill, | ||
syscall.SIGHUP, | ||
syscall.SIGINT, | ||
syscall.SIGQUIT, | ||
) | ||
defer cancel() | ||
|
||
dataset := os.Getenv("AXIOM_DATASET") | ||
if dataset == "" { | ||
log.Print("AXIOM_DATASET is required") | ||
return exitConfig | ||
} | ||
if ingestDataset == "" { | ||
log.Fatal("missing AXIOM_DATASET") | ||
|
||
client, err := axiom.NewClient() | ||
if err != nil { | ||
log.Print(err) | ||
return exitConfig | ||
} else if err = client.ValidateCredentials(ctx); err != nil { | ||
log.Print(err) | ||
return exitConfig | ||
} | ||
|
||
config := &server.Config{ | ||
URL: deploymentURL, | ||
Dataset: ingestDataset, | ||
Token: ingestToken, | ||
Dataset: dataset, | ||
AddrUDP: *addrUDP, | ||
AddrTCP: *addrTCP, | ||
} | ||
|
||
srv, err := server.NewServer(config) | ||
srv, err := server.NewServer(client, config) | ||
if err != nil { | ||
log.Fatal(err) | ||
log.Print(err) | ||
return exitInternal | ||
} | ||
|
||
srv.Run() | ||
|
||
return exitOK | ||
} |
Oops, something went wrong.