newrelic / infra-integrations-sdk

New Relic Infrastructure Integrations SDK
Apache License 2.0
44 stars 23 forks source link

Tutorial specifies v3 however the sample code uses v4 #277

Closed maguec closed 2 years ago

maguec commented 2 years ago

NOTE: # https://github.com/newrelic/infra-integrations-sdk/blob/master/docs/tutorial.md#building-a-redis-integration-using-the-integration-golang-sdk-v30 however https://github.com/newrelic/infra-integrations-sdk/blob/master/docs/tutorial-code/multiple-entities/redis-multi.go specifies v4

Description

NOTE: # When trying to build a custom integration that Flex is not able to meet requirements I'm running into the following log message

time=“2021-11-04T20:14:13Z” level=debug msg=“Missing event_type field for metric.” action=EmitDataSet component=PluginRunner integration= metric=“map[attributes:map[] label.env:production label.role:cache name:query.instantaneousOpsPerSecond timestamp:1.636056853e+09 type:gauge value:2112]”
$ ./myorg-redis-multi  --pretty --metrics
{
    "protocol_version": "4",
    "integration": {
        "name": "com.myorganization.redis-multi",
        "version": "0.1.0"
    },
    "data": [
        {
            "common": {},
            "entity": {
                "name": "instance-1",
                "displayName": "redis",
                "type": "instance-1",
                "metadata": {}
            },
            "metrics": [
                {
                    "timestamp": 1636057006,
                    "name": "query.instantaneousOpsPerSecond",
                    "type": "gauge",
                    "attributes": {},
                    "value": 2112
                }
            ],
            "inventory": {},
            "events": []
        },
        {
            "common": {},
            "entity": {
                "name": "instance-2",
                "displayName": "redis",
                "type": "my-instance",
                "metadata": {}
            },
            "metrics": [
                {
                    "timestamp": 1636057006,
                    "name": "query.instantaneousOpsPerSecond",
                    "type": "gauge",
                    "attributes": {},
                    "value": 2112
                }
            ],
            "inventory": {},
            "events": []
        }
    ]
}

This output does not include event_type, however the tutorial shows event_type.

Expected Behavior

The sample code is able to submit metrics without errors

Troubleshooting or NR Diag results

Steps to Reproduce

Install newrelic-infra 1.20.5

in /etc/newrelic-infra.yml

set

log_file: /tmp/newrelic.log
verbose: 1

grep event_type /tmp/newrelic.log

grab https://github.com/newrelic/infra-integrations-sdk/blob/master/docs/tutorial-code/multiple-entities/redis-multi.go

Your Environment

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"
$ dpkg --list |grep newrelic
ii  newrelic-infra                    1.20.5                              amd64        New Relic Infrastructure provides flexible, dynamic server monitoring. With real-time data collection and a UI that scales from a handful of hosts to thousands, Infrastructure is designed for modern Operations teams with fast-changing systems.
rogercoll commented 2 years ago

@maguec Thank you for reporting the issue.

We are going to add the corresponding sample code for v3 and update the tutorial files.