Skip to content

Adding support to parse metadata before headers to the CSV parser #10079

@etycomputer

Description

@etycomputer

Feature Request

Adding this option enables the parser to process metadata included before the CSV header.
This information can be included in every metric as a field or tag.

Proposal:

To add two new options to the CSV parser: csv_metadata_rows and csv_metadata_regex
csv_metadata_rows = x where x is the number of rows that contain the metadata after csv_skip_rows and before the header rows. By default, this value would be set to zero.

csv_metadata_regex = ["^[#]?\s*(?P<key>[^:=]+)[:=]\s*(?P<value>\w+)$"]

csv_metadata_regex is a list of regex expressions, each regex must have a key and value label.

The regex expression above covers the following scenarios:

# comment line
#	option 1: value1
	option 2= value2

	# another comment line
	option3: value3

and returns the following metadata:
option 1=value1
option 2=value2
option3=value3

Note that the regex could also be used to ignore comments.

Example CSV file:

version=1.0
file created: 2021-10-08T12:34:18+10:00
timestamp,type,name,status
2020-11-23T08:19:27+10:00,Reader,R002,1
2020-11-04T13:23:04+10:00,Reader,R031,0
2020-11-04T13:29:47+10:00,Coordinator,C001,1

Current behaviour:

The current parser does not support metadata parsing. These rows need to be skipped.

Desired behaviour:

The output should include version and file created as either a tag or a field for every metric following the header.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/csvcsv parser/serialiser relatedfeature requestRequests for new plugin and for new features to existing plugins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions