šŸ“” SNMP Extensions — Module 8

Build, Sign & Deploy

Tutorial

The Build Pipeline

You've written your extension.yaml with metrics, topology, screens, and func: metrics. Now let's turn it into a deployable package.

extension.yaml + snmp/ + dashboards/
  → dt ext assemble (creates extension.zip)
    → dt ext sign (creates bundle.zip)
      → Upload to Dynatrace (POST /api/v2/extensions)
        → Create monitoring configuration (POST .../monitoringConfigurations)
          → Data flows!

Step 1: Validate

Before building, always lint your extension. Our validator catches 21 types of errors:

python3 validate_extension.py ./ext/

# Output:
# ======================================================================
#   custom:com.dynatrace.extension.my-device v0.0.1
#   MIBs: 3 table defs from ./ext/snmp
# ======================================================================
#
# ERROR DED018: Subgroup "Interface Info" line 45: OID 1.3.6.1.2.1.4.20.1.1
#   is from ipAdEntTable but subgroup walks ifTable (cross-table mismatch)
#
# WARNING DED006: Metric "my_device.if.in.octets" line 52: count metric
#   should have .count suffix
#
# ======================================================================
#   RESULT: 1 errors, 1 warnings
# ======================================================================

Fix all errors before proceeding. Warnings are acceptable but should be addressed.

Step 2: Assemble

export PATH="/tmp/dtcli-venv/bin:$PATH"

dt ext assemble --source ./ext --output ./extension.zip

This creates extension.zip containing your extension.yaml, snmp/ MIBs, dashboards/, and alerts/.

Step 3: Sign

dt ext sign \
  --src ./extension.zip \
  --key /path/to/developer.pem \
  --output ./bundle.zip \
  --force

This creates bundle.zip — the final package containing extension.zip + extension.zip.sig.

Step 4: Upload CA Certificate

First time only — Dynatrace needs to trust your signing certificate.

Credential Vault (server-side)

CA_PEM=$(base64 -w0 ca.pem)

curl -X POST "$BASE/api/v2/credentials" \
  -H "Authorization: Api-Token $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Extension CA Certificate",
    "type": "PUBLIC_CERTIFICATE",
    "certificate": "'"$CA_PEM"'",
    "password": "",
    "scopes": ["EXTENSION"]
  }'

ActiveGate filesystem (runtime)

sudo cp ca.pem /var/lib/dynatrace/remotepluginmodule/agent/conf/certificates/
sudo systemctl restart dynatracegateway

Step 5: Upload Extension

curl -X POST "$BASE/api/v2/extensions" \
  -H "Authorization: Api-Token $TOKEN" \
  -F "file=@bundle.zip"

Dynatrace stores up to 10 versions. Only one can be active at a time.

Step 6: Activate Version

curl -X POST "$BASE/api/v2/extensions/custom:com.dynatrace.extension.my-device/environmentConfiguration" \
  -H "Authorization: Api-Token $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version": "0.0.1"}'

Step 7: Create Monitoring Configuration

curl -X POST "$BASE/api/v2/extensions/custom:com.dynatrace.extension.my-device/monitoringConfigurations" \
  -H "Authorization: Api-Token $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{
    "scope": "ag_group-default",
    "value": {
      "version": "0.0.1",
      "description": "Production monitoring",
      "enabled": true,
      "snmp": {
        "devices": [{
          "ip": "10.0.0.1",
          "port": 161,
          "authentication": {
            "type": "SNMPv2c",
            "community": "public"
          }
        }]
      },
      "featureSets": ["all"]
    }
  }]'

Verifying Data

After a few minutes, check that metrics are flowing:

# List registered metrics
curl "$BASE/api/v2/metrics?text=my_device" \
  -H "Authorization: Api-Token $TOKEN"

# Query actual data
curl "$BASE/api/v2/metrics/query?metricSelector=my_device.cpu_usage&from=now-1h" \
  -H "Authorization: Api-Token $TOKEN"

# Check entities
curl "$BASE/api/v2/entities?entitySelector=type(my_device:device)&fields=+properties" \
  -H "Authorization: Api-Token $TOKEN"

Version Updates

To update your extension:

  1. Bump version: in extension.yaml
  2. Validate → Assemble → Sign → Upload
  3. Activate the new version
  4. Update monitoring configurations to use the new version

Dynatrace keeps old versions. You can roll back by activating a previous version.

Quick Reference: Required Token Scopes

Scope              Purpose
─────────────────  ──────────────────────────────
extensions.read    Download/list extensions
extensions.write   Upload/activate extensions
metrics.read       Query metric data
entities.read      Query entities
settings.write     Deploy alerts
settings.read      Read alert configurations

Congratulations!

You've completed the SNMP Extensions track. You can now build a complete Dynatrace SNMP extension from scratch — with metrics, topology, screens, calculated metrics, and proper deployment.

Continue to the Python Track (Module 9) to learn how to build extensions for data sources that SNMP can't reach, or jump to the Production Track (Module 13) to learn alert creation and validation workflows.

šŸ›  Hands-On Exercise

Edit the YAML in the editor, then click "Check My Work" to validate.

Pre-Build Validation

This extension has multiple bugs that would fail in production. Find and fix them all before it can be built.

Bugs hidden in this YAML:

  • A scalar OID missing its .0 suffix
  • A table OID that incorrectly ends in .0
  • A count metric without the .count key suffix
  • A metric defined in snmp: but missing from metrics: metadata

Run the validator — your goal is 0 errors.

extension.yamlYAML
Loading...