-
Notifications
You must be signed in to change notification settings - Fork 633
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
invalid character on device description passes from snmp_exporter to prometheus - invalid utf-8 label #279
Comments
This is a device bug, it is only permitted to have ASCII characters in a DisplayString such as ifAlias. You should report this to your vendor. |
Device bug or not, this output needs to be filtered by the exporter to avoid exposing invalid data to Prometheus. |
@SuperQ I agree with your sentiment, but I do wonder what it should be changed to. Drop the label silently? Strip down é to e? If yes, what about ☺? |
The only correct action we can take is to fail the scrape, which is what we do. No invalid data enters Prometheus. Returning partial results or munging data which may for example cause non-uniqueness is a very bad idea semantically, it has to be all or nothing. The SNMP exporter works with SNMP, if the other end doesn't implement SNMP then we can't support it. |
Once #186 is in you could get the snmp exporter handle this as the arbitrary binary string that it is. There's only so much we can do with garbage data. |
We should fail the scrape at the exporter, rather than emit "corrupt" invalid data over the wire. |
We're using the Go client, so that's what we already do. Prometheus also has checks for this. |
Except, as you can see by this report, it's not happening. The snmp_exporter is emitting corrupted non-utf8 data. |
Ah, looks like we're using an older version of the go client. I did some work in this area about a year ago, and had presumed it had all propagated by now. |
Unrelated, I checked the output reported, what's getting passed to the exporter is |
#281 to update the client vendoring. |
@SuperQ just to deliberately think about it once. |
It's difficult when the "vendor" is Microsoft. Windows 2k12 reports ifAlias as a localized string. Using OctetString does the trick but the label is now mostly useless.
I tried to use regex replace to manually convert the hex bytestream back to a readable form. However, it looks like, understandably, it does not work with OctedString. It also sends null terminated strings as ifDescr. However, in this case, nobody seems to bother (I only noticed directly getting metrics from a browser). Anyway, it would be nice to chomp it off. Check byte 0x58:
|
DisplayString is effectively limited to 7-bit ASCII:
What we probably need to do is implement support for SnmpAdminString (defined in RFC 3411), which allows UTF-8 characters (and fix the generator README so that it doesn't say that UTF-8 is allowed for DisplayString). There are almost certainly cases where vendors may be using even more funky encodings like Shift JIS, KOI-8 etc. to stuff illegal values into non-conformant SNMP engines, so that might mean that we have to provide some kludges to work around that - since it's probably easier than getting vendors to fix their broken MIBs. The following minimal example shows that it would not take a lot of additional code to support input encoding translation to UTF-8: import (
"encoding/hex"
"fmt"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/transform"
)
func main() {
const s = "436F6E6578E36F204C6F63616C2A2036"
octetstr, _ := hex.DecodeString(s)
fmt.Printf("% x\n", octetstr)
fmt.Printf("%s\n", octetstr)
dec := charmap.ISO8859_1.NewDecoder()
res, _, _ := transform.Bytes(dec, octetstr)
fmt.Printf("% x\n", res)
fmt.Printf("%s\n", res)
}
|
Avoid sending raw invalid UTF-8 to metrics by replacing invalid chars with U+FFFD. Fixes: #279 Signed-off-by: SuperQ <superq@gmail.com>
Avoid sending raw invalid UTF-8 to metrics by replacing invalid chars with U+FFFD. Fixes: #279 Signed-off-by: SuperQ <superq@gmail.com>
Avoid sending raw invalid UTF-8 to metrics by replacing invalid chars with U+FFFD. Fixes: prometheus#279 Signed-off-by: SuperQ <superq@gmail.com> Signed-off-by: Stephan Windischmann <windi@Stephans-MacBook-Pro.local>
Some polled devices were marked as down even when snmp_exporter?target=... worked.
the target error in prom was "invalid utf-8 label".
The problem was an invalid character on the interface description. (Notélé)
Host operating system: output of
uname -a
Linux SBVCP-PROMETHEUS-01 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@SBVCP-PROMETHEUS-01 ~]# env | grep -i lang
LANG=en_US.UTF-8
snmp_exporter version: output of
snmp_exporter -version
]# ./snmp_exporter --version
snmp_exporter, version 0.9.0 (branch: HEAD, revision: abb143a)
build user: root@8246f0b1908c
build date: 20180226-16:10:54
go version: go1.9.2
What device/snmpwalk OID are you using?
on ifAlias
See the attached file as an example of the error.
(some alias have been
snmptarget=sw-xxx&module=xxx.txt
removed)
I changed the description and it worked. SuperQ mentionned this should be catched by snmp_exporter.
The text was updated successfully, but these errors were encountered: