Skip to content

Commit ff415c0

Browse files
authored
Merge pull request #27 from FireTail-io/dev
[MAIN] bug fixes
2 parents 3271710 + b853cdc commit ff415c0

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ dev: build-dev
2424
-e FIRETAIL_KUBERNETES_SENSOR_DEV_SERVER_ENABLED=true \
2525
-e DISABLE_SERVICE_IP_FILTERING=true \
2626
-e ENABLE_ONLY_LOG_JSON=true \
27+
-e FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES=0 \
2728
firetail/kubernetes-sensor-dev

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Firetail Kubernetes Sensor
22

3+
4+
35
## Deployment
46

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

13+
14+
1115
## Environment Variables
1216

1317
| Variable Name | Required? | Example | Description |
@@ -18,6 +22,7 @@
1822
| `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. |
1923
| `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. |
2024
| `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. |
25+
| `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. |
2126
| `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. |
2227
| `FIRETAIL_KUBERNETES_SENSOR_DEV_SERVER_ENABLED` || `true` | Enables a demo web server when set to `true`; useful for sending test requests to. |
2328

src/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ import (
1515
)
1616

1717
func main() {
18+
maxLifetimeMinutes, err := strconv.Atoi(os.Getenv("FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES"))
19+
if err != nil {
20+
slog.Warn(
21+
"FIRETAIL_KUBERNETES_SENSOR_LIFETIME_MINUTES environment variable not set. " +
22+
"This sensor will shutdown in 15 minutes.",
23+
)
24+
maxLifetimeMinutes = 15
25+
} else {
26+
if maxLifetimeMinutes > 0 {
27+
slog.Warn("This sensor will shutdown in " + strconv.Itoa(maxLifetimeMinutes) + " minute(s).")
28+
} else {
29+
slog.Warn("Shutdown timeout disabled. This sensor will run indefinitely.")
30+
}
31+
}
32+
if maxLifetimeMinutes > 0 {
33+
go func() {
34+
time.Sleep(time.Minute * time.Duration(maxLifetimeMinutes))
35+
slog.Warn("Timeout reached. Shutting down the sensor...")
36+
os.Exit(0)
37+
}()
38+
}
39+
1840
logsApiToken, logsApiTokenSet := os.LookupEnv("FIRETAIL_API_TOKEN")
1941
if !logsApiTokenSet {
2042
log.Fatal("FIRETAIL_API_TOKEN environment variable not set")

0 commit comments

Comments
 (0)