Telegraf Plugin: How to send data to output without encoding

Hi

I’m using snmp input plugin on telegraf to fetch data from my network devices, for a particular vendor and using vendor specific MIB, there are certain fields that are returning encoded values example :-

“ENCODED VALUE FROM TELEGRAF with --test”
outletDeviceCapabilities=“▒”

“DESIRED VALUE like snmpwalk”
PDU2-MIB::outletDeviceCapabilities.1.1 = BITS: 9F 04 02 00 00 00 00 00 rmsCurrent(0) rmsVoltage(3) activePower(4) apparentPower(5) powerFactor(6) activeEnergy(7) onOff(13) frequency(22)

Furthermore, I’m using output to elasticsearch, but unfortunately there is no "content_encoding = “identity” option available for it.

I even tried using socket.writer to try out content_encoding = “identity” feature to fix the issue but no luck.

Is there any other way possible to achieve it? I just dont want telegraf to encode my data.

Thank you in advance!

I think you could try with using a starlark processor and using the binary operators of the starlark language.

I don’t understand,
How does using binary operators solve the issue… please elaborate

Update: I tried mapping the values using enum processor, still no luck.

Thanks!

The snmp device is returning a series of bits indicating which capabilities are enabled. Telegraf does not know about that and interprets them as string characters, hence why you are receiving an unprintable character as it isn’t matching any UTF8 characters.

So a possible solution if you really want to gather this info with telegraf is to use bitwise operators to extract the individual bits…

Another solution is indeed to use the parser processor with bindata as data format.

1 Like

Gahh!! After 2 days of research,brainstorming getting support from @Hipska and trying to use bindata, content_encoding, processors.enum/processors.enum.mapping and what not…
Finally got it working… the solution is present in the snmp plugin itself!

For upcoming users… If you face the same issue for BITS fields just add

conversion = "enum(1)"

Under the BITS type field, it will just directly fetch the mappings from MIB itself,
A small prerequisite would be to enable snmp_translator = "gosmi"

Here’s a output of issue before and after fix.

**Before**:

outletDeviceCapabilities=“▒”

**After**:

outletDeviceCapabilities="rmsCurrent(0) rmsVoltage(3) activePower(4) apparentPower(5) powerFactor(6) activeEnergy(7) onOff(13) frequency(22)"