DataDog / integrations-extras

Community developed integrations and plugins for the Datadog Agent.
BSD 3-Clause "New" or "Revised" License
252 stars 726 forks source link

How to set 'instances: lists' in aws_pricing.d/conf.yaml ? (integration-extras/aws_pricing) #832

Open AhchimLee opened 3 years ago

AhchimLee commented 3 years ago

Hi I'm trying to set custom integration(aws_pricing) at an aws instance(linux). The aws_pricing had installed successfully by follow shell command: sudo -u dd-agent -s /bin/bash -c 'datadog-agent integration install -t datadog-aws_pricing==1.0.0' but errors occured in conf.d/aws_pricing.d/conf.yaml when restart datadog-agent. conf.yaml:

init_config:

instances:
  - i-04fbxxxxxxxxxxxxx
  - i-0654xxxxxxxxxxxxx
  - i-0da4xxxxxxxxxxxxx

error message:

  Config Errors
  ==============
    aws_pricing
    -----------
      yaml: unmarshal errors:
  line 4: cannot unmarshal !!str `i-04fb0...` into integration.RawMap
  line 5: cannot unmarshal !!str `i-06540...` into integration.RawMap
  line 6: cannot unmarshal !!str `i-0da45...` into integration.RawMap

How to setup conf.yaml file? thanks.

integration-extras/aws_pricing

hithwen commented 3 years ago

Your conf.yaml file needs to follow this format https://github.com/DataDog/integrations-extras/blob/master/aws_pricing/datadog_checks/aws_pricing/data/conf.yaml.example

Instances does not refer to ec2 instances, it refers to agent check instances (as in OOP instance)

AhchimLee commented 3 years ago

Your conf.yaml file needs to follow this format https://github.com/DataDog/integrations-extras/blob/master/aws_pricing/datadog_checks/aws_pricing/data/conf.yaml.example

Instances does not refer to ec2 instances, it refers to agent check instances (as in OOP instance)

You means create agent check instances configuration like below? https://docs.datadoghq.com/developers/write_agent_check/?tab=agentv6v7

And I edited aws_pricing.d/conf.yaml :

init_config:
instances:
  - region_name: us-east-1

But it doesn't work. (occured AWS Credential issue) :

=========
Collector
=========

  Running Checks
  ==============

    aws_pricing (1.0.0)
    -------------------
      Instance ID: aws_pricing:698d047c39b859c1 [ERROR]
      Configuration Source: file:/etc/datadog-agent/conf.d/aws_pricing.d/conf.yaml
      Total Runs: 91
      Metric Samples: Last Run: 0, Total: 0
      Events: Last Run: 0, Total: 0
      Service Checks: Last Run: 0, Total: 0
      Average Execution Time : 8ms
      Last Execution Date : 2021-03-27 10:12:35.000000 UTC
      Last Successful Execution Date : Never
      Error: Unable to locate credentials
      Traceback (most recent call last):
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/base/checks/base.py", line 901, in run
          self.check(instance)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/aws_pricing/aws_pricing.py", line 22, in check
          service_codes = get_aws_service_codes(pricing_client)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/aws_pricing/aws_pricing.py", line 70, in get_aws_service_codes
          response = pricing_client.describe_services(FormatVersion='aws_v1')
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/client.py", line 276, in _api_call
          return self._make_api_call(operation_name, kwargs)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/client.py", line 572, in _make_api_call
          http, parsed_response = self._make_request(
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/client.py", line 592, in _make_request
          return self._endpoint.make_request(operation_model, request_dict)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/endpoint.py", line 102, in make_request
          return self._send_request(request_dict, operation_model)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/endpoint.py", line 132, in _send_request
          request = self.create_request(request_dict, operation_model)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/endpoint.py", line 115, in create_request
          self._event_emitter.emit(event_name, request=request,
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/hooks.py", line 356, in emit
          return self._emitter.emit(aliased_event_name, **kwargs)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/hooks.py", line 228, in emit
          return self._emit(event_name, kwargs)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/hooks.py", line 211, in _emit
          response = handler(**kwargs)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/signers.py", line 90, in handler
          return self.sign(operation_name, request)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/signers.py", line 160, in sign
          auth.add_auth(request)
        File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/botocore/auth.py", line 357, in add_auth
          raise NoCredentialsError
      botocore.exceptions.NoCredentialsError: Unable to locate credentials

I guess configure Agent checks could be update AWS Credentials, but how to use it?

Otherwise, do AWS credentials have to be set up inside the instance? (Access/Secret Key)

thanks, again.

hithwen commented 3 years ago

Pinging @tsein-bc as the integration maintainer. @AhchimLee you can also find the maintainer's email on https://github.com/DataDog/integrations-extras/blob/master/.github/CODEOWNERS#L10

Intrusionz3r0 commented 3 years ago

Pudiste solucionarlo ?