Skip to content
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dev: build-dev
-e FIRETAIL_KUBERNETES_SENSOR_DEV_SERVER_ENABLED=true \
-e DISABLE_SERVICE_IP_FILTERING=true \
-e ENABLE_ONLY_LOG_JSON=true \
-e FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES=0 \
firetail/kubernetes-sensor-dev
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Firetail Kubernetes Sensor



## Deployment

- Create an API & API Key on the FireTail Platform
Expand All @@ -8,6 +10,8 @@
- ```git clone https://github.com/FireTail-io/firetail-kubernetes-sensor.git```
- deploy helm chart ```cd helm && helm install firetail-sensor firetail-sensor/ --set apiKey="PS-02-XXXXXXXX"```



## Environment Variables

| Variable Name | Required? | Example | Description |
Expand All @@ -18,6 +22,7 @@
| `ENABLE_ONLY_LOG_JSON` | ❌ | `true` | Enables only logging requests where the content-type implies the payload should be JSON, or the payload is valid JSON regardless of the content-type. |
| `DISABLE_SERVICE_IP_FILTERING` | ❌ | `true` | Disables polling Kubernetes for the IP addresses of services & subsequently ignoring all requests captured that aren't made to one of those IPs. |
| `FIRETAIL_API_URL` | ❌ | `https://api.logging.eu-west-1.prod.firetail.app/logs/bulk` | The API url the sensor will send logs to. Defaults to the EU region production environment. |
| `FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES` | ❌ | `15` | The maximum lifetime of the FireTail kubernetes sensor in minutes. Must be an integer. Values <=0 will disable the shutdown timer. |
| `FIRETAIL_KUBERNETES_SENSOR_DEV_MODE` | ❌ | `true` | Enables debug logging when set to `true`, and reduces the max age of a log in a batch to be sent to FireTail. |
| `FIRETAIL_KUBERNETES_SENSOR_DEV_SERVER_ENABLED` | ❌ | `true` | Enables a demo web server when set to `true`; useful for sending test requests to. |

Expand Down
22 changes: 22 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ import (
)

func main() {
maxLifetimeMinutes, err := strconv.Atoi(os.Getenv("FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES"))
if err != nil {
slog.Warn(
"FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES environment variable not set. " +
"This sensor will shutdown in 15 minutes.",
)
maxLifetimeMinutes = 15
} else {
if maxLifetimeMinutes > 0 {
slog.Warn("This sensor will shutdown in " + strconv.Itoa(maxLifetimeMinutes) + " minute(s).")
} else {
slog.Warn("Shutdown timeout disabled. This sensor will run indefinitely.")
}
}
if maxLifetimeMinutes > 0 {
go func() {
time.Sleep(time.Minute * time.Duration(maxLifetimeMinutes))
slog.Warn("Timeout reached. Shutting down the sensor...")
os.Exit(0)
}()
}

logsApiToken, logsApiTokenSet := os.LookupEnv("FIRETAIL_API_TOKEN")
if !logsApiTokenSet {
log.Fatal("FIRETAIL_API_TOKEN environment variable not set")
Expand Down