Skip to content

Commit 473355b

Browse files
add sqldb to schema (#96)
1 parent ecea4ea commit 473355b

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

schema.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,5 +617,64 @@ func (s *Schema) InjectLTSPlugins() {
617617
},
618618
},
619619
},
620+
}, SchemaSection{
621+
// See https://github.com/chronosphereio/calyptia-core-fluent-bit-plugin-sqldb
622+
Type: "input",
623+
Name: "sqldb",
624+
Description: "SQL Database input",
625+
Properties: SchemaProperties{
626+
Options: []SchemaOptions{
627+
{
628+
Name: "driver",
629+
Type: "string",
630+
Description: "The SQL driver to use. Allowed values are: postgres, mysql, oracle, sqlserver and sqlite.",
631+
Default: "postgres",
632+
},
633+
{
634+
Name: "dsn",
635+
Type: "string",
636+
Description: "Connection string to the database.",
637+
},
638+
{
639+
Name: "query",
640+
Type: "string",
641+
Description: `SQL query to perform. It supports "@named" arguments. See option columnsForArgs.`,
642+
},
643+
{
644+
Name: "columnsForArgs",
645+
Type: "string",
646+
Description: "Space separated list of columns. If you want to paginate over the data, you can convert the last row into arguments. Example id created_at will create two arguments that you can use in the query: @last_id and @last_created_at.",
647+
},
648+
{
649+
Name: "timeFrom",
650+
Type: "string",
651+
Description: "Column from which extract the log ingestion time. If not set, current time will be used.",
652+
},
653+
{
654+
Name: "timeFormat",
655+
Type: "string",
656+
Description: "Time format to use when timeFrom is set. Besides the standard RFCs time formats to parse strings, it can also parse integers by setting the format to: unix_sec, unix_ms, unix_us, or unix_ns (default for integers).",
657+
Default: "2006-01-02T15:04:05.999999999Z07:00",
658+
},
659+
{
660+
Name: "fetchInterval",
661+
Type: "string",
662+
Description: "Duration between executing each query. Cannot be less than 0.",
663+
Default: "1s",
664+
},
665+
{
666+
Name: "storageKey",
667+
Type: "string",
668+
Description: "Storage key used to store the query arguments to allow restart and resuming. Pass your own key to have more control, or to reset the arguments. The key should be unique and does not need to end with .gob.",
669+
Default: "sqldb_{hash}.gob",
670+
},
671+
{
672+
Name: "storageDir",
673+
Type: "string",
674+
Description: "Storage path where to store data. If default /data/storage does not exists, a temporary directory will be used.",
675+
Default: "/data/storage",
676+
},
677+
},
678+
},
620679
})
621680
}

validator_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,25 @@ func TestConfig_Validate(t *testing.T) {
335335
labels bar
336336
`,
337337
},
338+
{
339+
name: "in_sqldb_unknown_property",
340+
ini: `
341+
[INPUT]
342+
Name sqldb
343+
nope test
344+
`,
345+
want: `input: sqldb: unknown property "nope"`,
346+
},
347+
{
348+
name: "in_sqldb_ok",
349+
ini: `
350+
[INPUT]
351+
Name sqldb
352+
driver slite
353+
dsn file::memory:?cache=shared
354+
query SELECT 'hello from sqldb' AS message
355+
`,
356+
},
338357
}
339358
for _, tc := range tt {
340359
t.Run(tc.name, func(t *testing.T) {

0 commit comments

Comments
 (0)