Skip to content

Commit

Permalink
Added timerange config for graylog queries
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGeras committed Aug 27, 2024
1 parent 48cefcc commit 3936404
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ Tag = 'demo'
#Tag = "tkt"
#URL = "https://redmine.example.com"
#BearerToken = "example3f5bb1632f40bde25d315d53bdec83e"
#
#[[graylog]]
#Tag = 'graylog'
#URL = "https://graylog.example.com"
#TimeRange = 600 # query timerange in seconds
#Username = "example3f5bb1632f40bde25d315d53bdec83e"
#Password = "token"
12 changes: 9 additions & 3 deletions pkg/connectors/graylog/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ type Connector struct {
}

type Config struct {
Tag string
Cluster string
Tag string
Cluster string
TimeRange int
common.HTTPConfig
}

Expand Down Expand Up @@ -90,13 +91,18 @@ func (c *Connector) String() string {

func (c *Connector) collectAlertEvents(ctx context.Context) (eventsSearchResults, error) {
// TODO: Use pagination, however, we're unlikely to hit this limit for unresolved alerts
timeRangeSeconds := c.config.TimeRange
if timeRangeSeconds == 0 {
timeRangeSeconds = 600
}

body := eventsSearchParameters{
Query: "",
Page: 1,
PerPage: 100,
TimeRange: timeRange{
Type: TimeRangeRelative,
Range: 600,
Range: timeRangeSeconds,
},
}

Expand Down

0 comments on commit 3936404

Please sign in to comment.