<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SNMP Trap extension add attribute to log and custom device in Extensions</title>
    <link>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/253365#M4979</link>
    <description>&lt;P&gt;I found a sollution myself.&lt;BR /&gt;Its not ideal, but it works.&lt;BR /&gt;It would help if I would know the log/snmp-trap ingest pipeline, in some ordered list form.&lt;STRONG&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Important!&lt;/SPAN&gt;&lt;/STRONG&gt;Without these 3 log configurations, the setup does not work as intended.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create an aditional field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;application_name&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;in Log Processing, rule, based on &lt;EM&gt;the snmp.trap_oid field.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;USING(INOUT application_name:STRING?, snmp.trap_oid)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| FIELDS_ADD(application_name:IF_THEN_ELSE(snmp.trap_oid CONTAINS('.6876.'), "VMWARE",application_name))&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Add the field&amp;nbsp;application_name&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Log custom attributes, to make the field queryable.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Create a log metric log.snmptrap.count&amp;nbsp;, with matcher log.source="snmptraps" and dimensions application_name, device.address, snmp.trap_oid.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Extension:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;name: custom:com.dynatrace.extension.snmp-traps-generic
version: 0.1.6
minDynatraceVersion: 1.280.0
author:
  name: Debeste

metrics:
  - key: custom.extension.snmp-traps-generic.traps.count
    metadata:
      displayName: Traps count
      description: Number of traps received.
      unit: Count

snmptraps:
  - group: generic
    featureSet: Events
    interval:
      minutes: 1
    metrics:
      - key: custom.extension.snmp-traps-generic.traps.count
        type: count,delta
        value: calculated
    dimensions:
      - key: host_ip
        value: const:sender
      - key: trap_oid
        value: const:trapOID

        

topology:
  relationships:
    - fromType: custom:com_dynatrace_ext_snmp-traps-custom
      typeOfRelation: SAME_AS
      toType: network:device
      enabled: true
      sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: dt.ip_addresses
              sourceTransformation: To lower case
              destinationProperty: dt.ip_addresses
              destinationTransformation: To lower case
  types:
    - name: custom:com_dynatrace_ext_snmp-traps-custom
      displayName: SNMP Traps Device Custom
      enabled: true
      rules:
        - idPattern: snmp_traps_device_{application_name}_{device.address}
          instanceNamePattern: SNMP Traps source {application_name} {device.address}
          sources:
            - sourceType: Metrics
              condition: $prefix(log.snmptrap.count)
          attributes:
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{application_name}'
              key: application_name
              displayName: Application name
          requiredDimensions: []
        - idPattern: snmp_traps_device_{application_name}_{device.address}
          sources:
              - sourceType: Logs
          attributes: 
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{application_name}'
              key: application_name
              displayName: Application name
          requiredDimensions: 
            - key: log.source
              valuePattern: '$eq(snmptraps)'

screens:
  - entityType: custom:com_dynatrace_ext_snmp-traps-custom
    detailsSettings:
      layout:
        autoGenerate: false
        cards:
          - type: INJECTIONS
          - key: traps_charts
            type: CHART_GROUP
          - key: traps_logs
            type: LOGS
            width: FULL_SIZE
      staticContent:
        breadcrumbs:
          - displayName: SNMP Traps sources Custom
            entityType: custom:com_dynatrace_ext_snmp-traps-custom
            type: ENTITY_LIST_REF
        showAddTag: true
        showGlobalFilter: false
        showProblems: true
        showProperties: true
        showTags: true
    chartsCards:
      - key: traps_charts
        displayName: Trap statistics
        numberOfVisibleCharts: 2
        mode: NORMAL
        charts:
          - displayName: Traps Count
            graphChartConfig:
              metrics:
                - metricSelector: log.snmptrap.count:splitBy("device.address","application_name")
                  visualization:
                    displayName: Traps count
                    seriesType: COLUMN
            visualizationType: GRAPH_CHART
          - displayName: Trap OIDs
            graphChartConfig:
              metrics:
                - metricSelector: log.snmptrap.count:splitBy("device.address","application_name","snmp.trap_oid")
                  visualization:
                    seriesType: COLUMN
              stacked: true
            visualizationType: GRAPH_CHART
    logsCards:
      - key: traps_logs
        displayName: Trap details
        filterQuery: dt.source_entity inEntitySelector "$(entityConditions)"
        pageSize: 10
        showFiltering: true
        enablePaging: true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This results in the device names containing the application name &amp;amp; IP.&lt;BR /&gt;Aswell as adding this data as properties to the device.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="debeste_0-1723624029696.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21766i6B292DB2C3F9D915/image-size/medium?v=v2&amp;amp;px=400" role="button" title="debeste_0-1723624029696.png" alt="debeste_0-1723624029696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This setup can be simplified hugely, if it would be possible to link a VAR from the extension config to the custom device properties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2024 08:32:46 GMT</pubDate>
    <dc:creator>debeste</dc:creator>
    <dc:date>2024-08-14T08:32:46Z</dc:date>
    <item>
      <title>SNMP Trap extension add attribute to log and custom device</title>
      <link>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/252934#M4961</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The snmp Trap extension does not make it easy to know, which log/custom device is created by which extension config. On the custom devices created, the only attribute present is the&amp;nbsp;dt.ip_addresses.&lt;BR /&gt;I have multiple applications sending snmp traps, each having their own support team.&lt;BR /&gt;So I have to create auto tag rules for each device sending traps, based on IP.&lt;BR /&gt;&lt;BR /&gt;Example:&amp;nbsp;type(snmptraps:com_dynatrace_ext_snmp-traps),dt.ip_addresses(99.4.50.24)&lt;BR /&gt;Repeat 100x &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it would help if I could add a variable in the extension config "application-name" thats then added to the log entry and custom device.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is it possible to add vars to log attributes?&lt;BR /&gt;And how to achieve this for the snmp trap extension, as only the metric is defined here?&lt;BR /&gt;I was thinking about something like this, but it does not work as the custom devices only take their properties from the log records (&amp;amp; metrics) its seems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My non working custom extension, to give some more context.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;name: custom:com.dynatrace.extension.snmp-traps-generic
version: 0.0.3
minDynatraceVersion: 1.280.0
author:
  name: Dynatrace

metrics:
  - key: com.dynatrace.extension.snmp-traps-generic.traps.count
    metadata:
      displayName: Traps count
      description: Number of traps received.
      unit: Count

snmptraps:
  - group: generic
    featureSet: Events
    interval:
      minutes: 1
    metrics:
      - key: com.dynatrace.extension.snmp-traps-generic.traps.count
        type: count,delta
        value: calculated
    dimensions:
      - key: host_ip
        value: const:sender
      - key: trap_oid
        value: const:trapOID
      - key: application_name
        value: var:application-name
        

vars:
  - id: application-name
    displayName: Application name
    description: "The name of the application integrated through snmp traps"
    type: text


topology:
  relationships:
    - fromType: custom:com_dynatrace_ext_snmp-traps
      typeOfRelation: SAME_AS
      toType: network:device
      enabled: true
      sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: dt.ip_addresses
              sourceTransformation: To lower case
              destinationProperty: dt.ip_addresses
              destinationTransformation: To lower case
  types:
    - name: custom:com_dynatrace_ext_snmp-traps
      displayName: SNMP Traps Device
      enabled: true
      rules:
        - idPattern: snmp_traps_device_{application_name}_{host_ip}
          instanceNamePattern: SNMP Traps source {application_name} {host_ip}
          sources:
            - sourceType: Metrics
              condition: $prefix(com.dynatrace.extension.snmp-traps-generic.traps.count)
          attributes:
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{host_ip}'
              key: host_ip
              displayName: IP Address
            - pattern: var:application-name
              key: application_name
              displayName: Application name
          requiredDimensions: []
        - idPattern: snmp_traps_device_{application_name}_{host_ip}
          sources:
              - sourceType: Logs
          attributes: 
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{host_ip}'
              key: host_ip
              displayName: IP Address
            - pattern: var:application-name
              key: application_name
              displayName: Application name
          requiredDimensions: 
            - key: log.source
              valuePattern: '$eq(snmptraps)'

screens:
  - entityType: custom:com_dynatrace_ext_snmp-traps
    detailsSettings:
      layout:
        autoGenerate: false
        cards:
          - type: INJECTIONS
          - key: traps_charts
            type: CHART_GROUP
          - key: traps_logs
            type: LOGS
            width: FULL_SIZE
      staticContent:
        breadcrumbs:
          - displayName: SNMP Traps sources
            entityType: custom:com_dynatrace_ext_snmp-traps
            type: ENTITY_LIST_REF
        showAddTag: true
        showGlobalFilter: false
        showProblems: true
        showProperties: true
        showTags: true
    chartsCards:
      - key: traps_charts
        displayName: Trap statistics
        numberOfVisibleCharts: 2
        mode: NORMAL
        charts:
          - displayName: Traps Count
            graphChartConfig:
              metrics:
                - metricSelector: com.dynatrace.extension.snmp-traps-generic.traps.count:splitBy()
                  visualization:
                    displayName: Traps count
                    seriesType: COLUMN
            visualizationType: GRAPH_CHART
          - displayName: Trap OIDs
            graphChartConfig:
              metrics:
                - metricSelector: com.dynatrace.extension.snmp-traps-generic.traps.count:splitBy("trapoid")
                  visualization:
                    seriesType: COLUMN
              stacked: true
            visualizationType: GRAPH_CHART
    logsCards:
      - key: traps_logs
        displayName: Trap details
        filterQuery: dt.source_entity inEntitySelector "$(entityConditions)"
        pageSize: 10
        showFiltering: true
        enablePaging: true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 14:32:42 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/252934#M4961</guid>
      <dc:creator>debeste</dc:creator>
      <dc:date>2024-08-08T14:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: SNMP Trap extension add attribute to log and custom device</title>
      <link>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/253365#M4979</link>
      <description>&lt;P&gt;I found a sollution myself.&lt;BR /&gt;Its not ideal, but it works.&lt;BR /&gt;It would help if I would know the log/snmp-trap ingest pipeline, in some ordered list form.&lt;STRONG&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Important!&lt;/SPAN&gt;&lt;/STRONG&gt;Without these 3 log configurations, the setup does not work as intended.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create an aditional field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;application_name&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;in Log Processing, rule, based on &lt;EM&gt;the snmp.trap_oid field.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;USING(INOUT application_name:STRING?, snmp.trap_oid)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| FIELDS_ADD(application_name:IF_THEN_ELSE(snmp.trap_oid CONTAINS('.6876.'), "VMWARE",application_name))&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Add the field&amp;nbsp;application_name&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Log custom attributes, to make the field queryable.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Create a log metric log.snmptrap.count&amp;nbsp;, with matcher log.source="snmptraps" and dimensions application_name, device.address, snmp.trap_oid.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Extension:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;name: custom:com.dynatrace.extension.snmp-traps-generic
version: 0.1.6
minDynatraceVersion: 1.280.0
author:
  name: Debeste

metrics:
  - key: custom.extension.snmp-traps-generic.traps.count
    metadata:
      displayName: Traps count
      description: Number of traps received.
      unit: Count

snmptraps:
  - group: generic
    featureSet: Events
    interval:
      minutes: 1
    metrics:
      - key: custom.extension.snmp-traps-generic.traps.count
        type: count,delta
        value: calculated
    dimensions:
      - key: host_ip
        value: const:sender
      - key: trap_oid
        value: const:trapOID

        

topology:
  relationships:
    - fromType: custom:com_dynatrace_ext_snmp-traps-custom
      typeOfRelation: SAME_AS
      toType: network:device
      enabled: true
      sources:
        - sourceType: Entities
          mappingRules:
            - sourceProperty: dt.ip_addresses
              sourceTransformation: To lower case
              destinationProperty: dt.ip_addresses
              destinationTransformation: To lower case
  types:
    - name: custom:com_dynatrace_ext_snmp-traps-custom
      displayName: SNMP Traps Device Custom
      enabled: true
      rules:
        - idPattern: snmp_traps_device_{application_name}_{device.address}
          instanceNamePattern: SNMP Traps source {application_name} {device.address}
          sources:
            - sourceType: Metrics
              condition: $prefix(log.snmptrap.count)
          attributes:
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{application_name}'
              key: application_name
              displayName: Application name
          requiredDimensions: []
        - idPattern: snmp_traps_device_{application_name}_{device.address}
          sources:
              - sourceType: Logs
          attributes: 
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: Device Address
            - pattern: '{application_name}'
              key: application_name
              displayName: Application name
          requiredDimensions: 
            - key: log.source
              valuePattern: '$eq(snmptraps)'

screens:
  - entityType: custom:com_dynatrace_ext_snmp-traps-custom
    detailsSettings:
      layout:
        autoGenerate: false
        cards:
          - type: INJECTIONS
          - key: traps_charts
            type: CHART_GROUP
          - key: traps_logs
            type: LOGS
            width: FULL_SIZE
      staticContent:
        breadcrumbs:
          - displayName: SNMP Traps sources Custom
            entityType: custom:com_dynatrace_ext_snmp-traps-custom
            type: ENTITY_LIST_REF
        showAddTag: true
        showGlobalFilter: false
        showProblems: true
        showProperties: true
        showTags: true
    chartsCards:
      - key: traps_charts
        displayName: Trap statistics
        numberOfVisibleCharts: 2
        mode: NORMAL
        charts:
          - displayName: Traps Count
            graphChartConfig:
              metrics:
                - metricSelector: log.snmptrap.count:splitBy("device.address","application_name")
                  visualization:
                    displayName: Traps count
                    seriesType: COLUMN
            visualizationType: GRAPH_CHART
          - displayName: Trap OIDs
            graphChartConfig:
              metrics:
                - metricSelector: log.snmptrap.count:splitBy("device.address","application_name","snmp.trap_oid")
                  visualization:
                    seriesType: COLUMN
              stacked: true
            visualizationType: GRAPH_CHART
    logsCards:
      - key: traps_logs
        displayName: Trap details
        filterQuery: dt.source_entity inEntitySelector "$(entityConditions)"
        pageSize: 10
        showFiltering: true
        enablePaging: true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This results in the device names containing the application name &amp;amp; IP.&lt;BR /&gt;Aswell as adding this data as properties to the device.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="debeste_0-1723624029696.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/21766i6B292DB2C3F9D915/image-size/medium?v=v2&amp;amp;px=400" role="button" title="debeste_0-1723624029696.png" alt="debeste_0-1723624029696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This setup can be simplified hugely, if it would be possible to link a VAR from the extension config to the custom device properties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 08:32:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/253365#M4979</guid>
      <dc:creator>debeste</dc:creator>
      <dc:date>2024-08-14T08:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: SNMP Trap extension add attribute to log and custom device</title>
      <link>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/258630#M5286</link>
      <description>&lt;P&gt;I agree that this would really be very practical to be able to use "var:" in custom extensions based on SNMP Traps.&amp;nbsp;&amp;nbsp;Furthermore, it looks like a bug because the use of variables works fine with the datasource "snmp" (in poll mode) but does not work with "snmptraps".&amp;nbsp;The problem is that in certain cases, the workaround with log processing is not possible if the expected information is not present in the content of the SNMP Trap received.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 17:22:08 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Extensions/SNMP-Trap-extension-add-attribute-to-log-and-custom-device/m-p/258630#M5286</guid>
      <dc:creator>MatthieuA</dc:creator>
      <dc:date>2024-10-08T17:22:08Z</dc:date>
    </item>
  </channel>
</rss>

