Error
$ datadog-agent status | grep event
event_example
Check event_example not found in Catalog
unable to import module 'event_example': unexpected indent (event_example.py, line 1)
Traces: 0 payloads, 0 traces, 0 events, 0 bytes
Solution
Correct the indent of the python file as below;
file name – event_example.py
from datadog_checks.base import AgentCheck
__version__ = "1.0.0"
class MyClass(AgentCheck):
def check(self, instance):
self.event(
{
"timestamp": time.time(),
"event_type": "Error",
"msg_title": "Example Event",
"msg_text": "This is an example event coming from Datadog.",
"alert_type": "error",
}
)
Another Error
event_example (1.0.0)
---------------------
Instance ID: event_example:d884b5186b651429 [ERROR]
Configuration Source: file:/etc/datadog-agent/conf.d/event_example.d/event_example.yaml
Total Runs: 13
Metric Samples: Last Run: 0, Total: 0
Events: Last Run: 0, Total: 0
Service Checks: Last Run: 0, Total: 0
Average Execution Time : 4ms
Last Execution Date : 2022-06-28 08:06:36 EDT / 2022-06-28 12:06:36 UTC (1656417996000)
Last Successful Execution Date : Never
Error: name 'time' is not defined
Traceback (most recent call last):
File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/base/checks/base.py", line 1120, in run
self.check(instance)
File "/etc/datadog-agent/checks.d/event_example.py", line 9, in check
"timestamp": time.time(),
NameError: name 'time' is not defined
Latest posts by rajeshkumar (see all)
- Ansible ERROR! ‘import’ is not a valid attribute for a Play - August 8, 2023
- Ansible Error: module whether to use the yum (yum3) or dnf (yum4) backend}) - August 7, 2023
- Kubernetes Gateway selection for Istio in Knative - August 7, 2023