Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wanted help parsing xml data with telegraf #65

Open
pratikdas44 opened this issue Jul 7, 2021 · 2 comments
Open

Wanted help parsing xml data with telegraf #65

pratikdas44 opened this issue Jul 7, 2021 · 2 comments

Comments

@pratikdas44
Copy link

My xml data is -
<root> <measEntity localDn="VNFID=bangloreiit-5005cucp1; gNBID=5005; gNBName=;" swVersion="6.0.00.49.6"/> <measData> <measInfo measInfoId="OR.end"> <granPeriod duration="PT300S" endTime="2021-07-02T17:10:00+00:00"/> <measTypes>SgnbAddAttemptCell.enb.0 SgnbAddAttemptCell.enb.1 SgnbAddAttemptCell.enb.2 SgnbAddAttemptCell.enb.3</measTypes> <measResults>0 0 0 0</measResults> </measInfo> </measData> </root>

I wanted to parse it using telegraf. I am able to get measurement, but currently i am facing 2 challenges:

Tag name - measEntity will provide tag name; eg - tag VNFID with value bangaloreiit-5005cucp1 and so on. But i am not able to get the tags.

Field name - Using measTypes i want to get the fieldnames which are separated by space- eg - SgnbAddAttemptCell.enb.0, SgnbAddAttemptCell.enb.1 and so on and their respective values inside measResults portion. I tried using tokenize but it was giving error in telegraf. Any way to do that using other predefined functions?

@Hipska
Copy link

Hipska commented May 4, 2022

Hi, it seems like we are trying to do the same, but my xml looks a bit different: (simplified)

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="MeasDataCollection.xsl"?>
<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
	<measData>
		<managedElement localDn="foobar.example.com" />
		<measInfo measInfoId="metric_name">
			<job jobId="job_name" />
			<granPeriod duration="PT900S" endTime="2022-04-20T15:15:01+02:00" />
			<repPeriod duration="PT900S" />
			<measType p="1">field1</measType>
			<measType p="2">field2</measType>
			<measValue measObjLdn="identifier">
				<r p="1">31854</r>
				<r p="2">159773</r>
			</measValue>
		</measInfo>
	</measData>
</measCollecFile>

Anyway, for your schema, I would collect @localDn and measTypes as tags and measResults as string field, so telegraf can process them later with for example starlark processor for parsing the actual fields based on measTypes and measResults, and process the localdn with for example logfmt parser.

@srebhan
Copy link
Contributor

srebhan commented Jun 13, 2022

@pratikdas44 please discuss this in the telegraf Slack channel or open an issue for telegraf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants