Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ys dynatrace event collector #38369

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

YaelShamai
Copy link
Contributor

Contributing to Cortex XSOAR Content

Make sure to register your contribution by filling the contribution registration form

The Pull Request will be reviewed only after the contribution registration form is filled.

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

fixes: https://jira-dc.paloaltonetworks.com/browse/CIAC-6409

Description

Dynatrace event collector

Must have

  • Tests
  • Documentation

Copy link

github-actions bot commented Jan 28, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
Packs/Dynatrace/Integrations/Dynatrace
   Dynatrace.py1681094%49, 306, 308–312, 314–315, 317
TOTAL1681094% 

Tests Skipped Failures Errors Time
20 0 💤 0 ❌ 0 🔥 1.635s ⏱️

@YaelShamai YaelShamai requested a review from JasBeilin January 28, 2025 10:54
Copy link
Contributor

@JasBeilin JasBeilin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, To be Continued..

Packs/Dynatrace/Integrations/Dynatrace/README.md Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.yml Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.py Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.py Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.py Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.py Outdated Show resolved Hide resolved
Packs/Dynatrace/Integrations/Dynatrace/Dynatrace.py Outdated Show resolved Hide resolved
Copy link
Contributor

@JasBeilin JasBeilin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change the fetch.

Comment on lines +69 to +71
field_mapping = {
"Audit logs": ["Audit", "timestamp"],
"APM": ["APM", "startTime"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit hard for future enhancements to change, consider changing it to a pre defined dictionary, we can discuss it further.

events_count = 0
args = {}

for i in range(7): # Design says we will do at most five calls every fetch_interval so we can get more events per fetch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is usually not the way we do it but getting a limit and going in loops until we get the amount of events.


demisto.debug(f"Dynatrace fetch APM {i+1} times in loop. calling query with {args=}")
response = events_query(client, args, "APM")
num_events = len(response.get("events"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after dedup

args["apm_from"] = last_run["last_timestamp"] + 1

demisto.debug(f"Dynatrace fetch APM {i+1} times in loop. calling query with {args=}")
response = events_query(client, args, "APM")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response = events_query(client, args, "APM")
response = events_query(client, args, "APM")
dedup_events = []

# If no events were retrieved, we retain the same last_timestamp as before,
# In cases where no events were retrieved and this is the first run (i.e., no last_run_timestamp exists),
# the query will use start_fetch_time again in the next execution.
last_run_to_save["last_timestamp"] = response.get("events")[0]["startTime"] if response["totalCount"] != 0 else (last_run.get("last_timestamp") or fetch_start_time)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider the last timestamp regardless of total count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants