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

Allow otel to support snmp traps. #698

Merged
merged 3 commits into from
Apr 27, 2024
Merged

Allow otel to support snmp traps. #698

merged 3 commits into from
Apr 27, 2024

Conversation

i3149
Copy link
Contributor

@i3149 i3149 commented Apr 22, 2024

I think this is good now. Tested with:

OTEL_METRIC_EXPORT_INTERVAL=30000 KENTIK_PING_PRIV=false ./bin/ktranslate -snmp snmp.yaml -format otel -otel.protocol grpc -otel.endpoint http://localhost:4317/

And otel config of:

pye ~/tmp $ cat contrib.yaml 
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4222

exporters:
    file:
      path: ./filename.json

service:
  extensions: []
  pipelines:
    metrics:
      receivers: [otlp]
      processors: []
      exporters: [file]
    logs:
      receivers: [otlp]
      processors: []
      exporters: [file]  

Both metrics and trap events were received.

@i3149 i3149 added the wip Work In Progress label Apr 22, 2024
@i3149 i3149 requested a review from jryburn April 25, 2024 05:46
@i3149 i3149 removed the wip Work In Progress label Apr 25, 2024
@i3149 i3149 changed the title wip for otel and trap handling Allow otel to support snmp traps. Apr 25, 2024
@i3149
Copy link
Contributor Author

i3149 commented Apr 25, 2024

I'm using slog to format the received traps. End result looks like:

{
  "resourceLogs": [
    {
      "resource": {
        "attributes": [
          {
            "key": "service.name",
            "value": {
              "stringValue": "ktranslate"
            }
          }
        ]
      },
      "scopeLogs": [
        {
          "scope": {
            "name": "github.com/agoda-com/otelslog",
            "version": "0.0.1"
          },
          "logRecords": [
            {
              "timeUnixNano": "1714024418038151000",
              "observedTimeUnixNano": "1714024418038151000",
              "severityNumber": 9,
              "severityText": "INFO",
              "body": {
                "stringValue": "New Trap Event"
              },
              "attributes": [
                {
                  "key": "instrumentation.name",
                  "value": {
                    "stringValue": "snmp-trap-events"
                  }
                },
                {
                  "key": "tags.location",
                  "value": {
                    "stringValue": "$SysDescr"
                  }
                },
                {
                  "key": "provider",
                  "value": {
                    "stringValue": "kentik-trap-device"
                  }
                },
                {
                  "key": "tags.test",
                  "value": {
                    "stringValue": "one"
                  }
                },
                {
                  "key": "src_addr",
                  "value": {
                    "stringValue": "127.0.0.1"
                  }
                },
                {
                  "key": "message",
                  "value": {
                    "stringValue": "ddd~"
                  }
                },
                {
                  "key": "instrumentation.provider",
                  "value": {
                    "stringValue": "kentik"
                  }
                },
                {
                  "key": "TrapName",
                  "value": {
                    "stringValue": "bigipServiceDown"
                  }
                },
                {
                  "key": "TrapOID",
                  "value": {
                    "stringValue": ".1.3.6.1.4.1.3375.2.4.0.10"
                  }
                },
                {
                  "key": "collector.name",
                  "value": {
                    "stringValue": "ktranslate"
                  }
                },
                {
                  "key": "device_name",
                  "value": {
                    "stringValue": "127.0.0.1"
                  }
                },
                {
                  "key": "eventType",
                  "value": {
                    "stringValue": "KSnmpTrap"
                  }
                }
              ],
              "traceId": "",
              "spanId": ""
            }
          ],
          "schemaUrl": "https://opentelemetry.io/schemas/1.21.0"
        }
      ]
    }
  ]
}

Copy link

@jryburn jryburn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good but I would like to clarify the architecture. Is the idea that ktranslate accepts SNMP traps and turns that into Otel events or that it accepts syslog and turns that in Otel SNMP traps or something else?

The reason I ask is that we have a customer, Telxius, who wants to receive "traps from Kentik" when a DDoS alerting policy fires off so they can integrate with Netcool the way their existing DDoS detection system does. I am thinking we might be able to build a creative solution where our notification system sends a webhook or syslog to ktranslate that turns that into an SNMP trap that is sent to Netcool. We could just run ktranslate on their cluster and it would look to them like we are sending traps.

@i3149
Copy link
Contributor Author

i3149 commented Apr 27, 2024

Is the idea that ktranslate accepts SNMP traps and turns that into Otel events or that it accepts syslog and turns that in Otel SNMP traps or something else?

The idea is that ktranslate accepts all SNMP traps like normal. When the otel format is selected, it will output a log to the otel collector as specified on the command line.

For the Telxius use case I'll flip things around and make ktrans be able to turn the webhook from kentik alerting into a trap send. We'll have to make up some oids for this but shouldn't be too hard.

@i3149 i3149 merged commit f55bce6 into main Apr 27, 2024
1 check passed
@i3149 i3149 deleted the otel-trap-handler branch April 27, 2024 04:25
@araddas araddas mentioned this pull request Oct 17, 2024
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

Successfully merging this pull request may close these issues.

2 participants