Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Dec 29, 2023
1 parent c94912d commit 3d7dfd1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var (
config *types.Configuration
stats *types.Statistics
promStats *types.PromStatistics
initParams *types.InitParams
initClientArgs *types.InitClientArgs

regPromLabels *regexp.Regexp
)
Expand Down Expand Up @@ -125,7 +125,7 @@ func init() {
DogstatsdClient: dogstatsdClient,
}

initParams = &types.InitParams{
initClientArgs = &types.InitClientArgs{
Config: config,
Stats: stats,
DogstatsdClient: dogstatsdClient,
Expand Down Expand Up @@ -262,7 +262,7 @@ func init() {
endpointUrl := fmt.Sprintf("%s/%s/%s/ingest", config.Quickwit.HostPort, config.Quickwit.ApiEndpoint, config.Quickwit.Index)
quickwitClient, err = outputs.NewClient("Quickwit", endpointUrl, config.Quickwit.MutualTLS, config.Quickwit.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
if err == nil {
err = quickwitClient.AutoCreateQuickwitIndex(*initParams)
err = quickwitClient.AutoCreateQuickwitIndex(*initClientArgs)
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion outputs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type Client struct {
}

// InitClient returns a new output.Client for accessing the different API.
func InitClient(outputType string, defaultEndpointURL string, mutualTLSEnabled bool, checkCert bool, params types.InitParams) (*Client, error) {
func InitClient(outputType string, defaultEndpointURL string, mutualTLSEnabled bool, checkCert bool, params types.InitClientArgs) (*Client, error) {
return NewClient(outputType, defaultEndpointURL, mutualTLSEnabled, checkCert, params.Config, params.Stats, params.PromStats, params.StatsdClient, params.DogstatsdClient)
}

Expand Down
25 changes: 21 additions & 4 deletions outputs/quickwit.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type QuickwitDocMapping struct {
FieldMappings []QuickwitFieldMapping `json:"field_mappings"`
Mode string `json:"mode"`
StoreSource bool `json:"store_source"`
TimestampField bool `json:"timestamp_field"`
TimestampField string `json:"timestamp_field"`
}

type QuickwitMappingPayload struct {
Expand All @@ -59,7 +59,7 @@ type QuickwitMappingPayload struct {
DocMapping QuickwitDocMapping `json:"doc_mapping"`
}

func (c *Client) AutoCreateQuickwitIndex(params types.InitParams) error {
func (c *Client) AutoCreateQuickwitIndex(params types.InitClientArgs) error {
config := params.Config.Quickwit
if config.AutoCreateIndex {
endpointUrl := fmt.Sprintf("%s/%s/indexes", config.HostPort, config.ApiEndpoint)
Expand All @@ -72,7 +72,9 @@ func (c *Client) AutoCreateQuickwitIndex(params types.InitParams) error {
Id: config.Index,
Version: config.IndexVersion,
DocMapping: QuickwitDocMapping{
Mode: "dynamic",
Mode: "dynamic",
StoreSource: true,
TimestampField: "time",
DynamicMapping: QuickwitDynamicMapping{
Description: "Falco",
Fast: true,
Expand All @@ -88,15 +90,30 @@ func (c *Client) AutoCreateQuickwitIndex(params types.InitParams) error {
Type: "datetime",
Fast: true,
},
{
Name: "priority",
Type: "i64",
Fast: true,
},
{
Name: "source",
Type: "text",
Fast: true,
},
{
Name: "output",
Type: "string",
Fast: true,
},
{
Name: "rule",
Type: "string",
Fast: true,
},
},
},
SearchSettings: QuickwitSearchSettings{
DefaultSearchFields: []string{"source"},
DefaultSearchFields: []string{"source", "output"},
},
}

Expand Down
4 changes: 2 additions & 2 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ type Configuration struct {
Dynatrace DynatraceOutputConfig
}

// InitParams represent a client parameters for initialization
type InitParams struct {
// InitClientArgs represent a client parameters for initialization
type InitClientArgs struct {
Config *Configuration
Stats *Statistics
PromStats *PromStatistics
Expand Down

0 comments on commit 3d7dfd1

Please sign in to comment.