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

Splunk OnCall migration tool #4267

Merged
merged 5 commits into from May 14, 2024
Merged

Conversation

joeyorlando
Copy link
Collaborator

@joeyorlando joeyorlando commented Apr 23, 2024

What this PR does

Refactors the PagerDuty migration script to be a bit more generic + adds a migration script to migrate from Splunk OnCall (VictorOps)

tldr;

❯ docker build -t oncall-migrator .
[+] Building 0.4s (10/10) FINISHED
❯ docker run --rm \
-e MIGRATING_FROM="pagerduty" \
-e MODE="plan" \
-e ONCALL_API_URL="http://localhost:8080" \
-e ONCALL_API_TOKEN="<ONCALL_API_TOKEN>" \
-e PAGERDUTY_API_TOKEN="<PAGERDUTY_API_TOKEN>" \
oncall-migrator
running pagerduty migration script...

❯ docker run --rm \
-e MIGRATING_FROM="splunk" \
-e MODE="plan" \
-e ONCALL_API_URL="http://localhost:8080" \
-e ONCALL_API_TOKEN="<ONCALL_API_TOKEN>" \
-e SPLUNK_API_ID="<SPLUNK_API_ID>" \
-e SPLUNK_API_KEY="<SPLUNK_API_KEY>" \
oncall-migrator
migrating from splunk oncall...

https://www.loom.com/share/a855062d436a4ef79f030e22528d8c71

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • Added the relevant release notes label (see labels prefixed w/ release:). These labels dictate how your PR will
    show up in the autogenerated release notes.

@joeyorlando joeyorlando self-assigned this Apr 23, 2024
@joeyorlando joeyorlando added the release:enhancement PR will be added to "Exciting New Features 🎉" section of release notes label Apr 23, 2024
@joeyorlando joeyorlando marked this pull request as ready for review May 3, 2024 19:06
@joeyorlando joeyorlando requested review from a team as code owners May 3, 2024 19:06
@joeyorlando joeyorlando changed the title [WIP] Splunk OnCall migration tool Splunk OnCall migration tool May 3, 2024
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this has been moved to [tools/migrators/add_users_to_grafana.py](https://github.com/grafana/oncall/pull/4267/files#diff-2b8ae690c66ef69beb40bffa232e3d9a03be89122cb0864ecae24b36ffa5156a) (+ slightly refactored to support migrating users from Splunk OnCall -> Grafana OnCall)

Copy link
Collaborator

@matiasb matiasb left a comment

Choose a reason for hiding this comment

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

LGTM, minor questions added (and nice to see complex schedule test cases! 👍 )

- the following Splunk OnCall escalation step types are not supported and will not be migrated:
- "Notify the next user(s) in the current on-duty shift"
- "Notify the previous user(s) in the current on-duty shift"
- "Notify every member of this team"
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be sure, isn't this equivalent to our "Notify all users from a team" step?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, it is. However, we don't currently have a script to migrate Splunk (or PagerDuty) teams to Grafana/Grafana OnCall teams (I considered adding it, and even left most of the code for it there, but commented out)

I suppose we could support this escalation step type and attempt to find the team match, and if we don't, just skip it. Maybe I'll do a follow up PR with support for this 👍

tools/migrators/add_users_to_grafana.py Outdated Show resolved Hide resolved
tools/migrators/lib/oncall/api_client.py Show resolved Hide resolved
Convert a Splunk datetime string to a datetime object.
"""
dt = datetime.datetime.strptime(text, "%Y-%m-%dT%H:%M:%SZ")
return dt.replace(tzinfo=datetime.timezone.utc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be sure, do we get TZ information from the Splunk API? are we potentially overriding that by the replace above? or do we always expect to get UTC timestamps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's okay here. They return the timezone, but they also return the start attribute in UTC. Just double checked their API response for schedule rotation shifts:

{
  "label": "multi-day stuff",
  "timezone": "America/Toronto",
  "start": "2024-04-24T21:00:00Z",
  "duration": 7,
  "shifttype": "cstm",
  "periods": [],
  "current": {},
  "next": {},
  "shiftMembers": [
    {
      "username": "joeyorlando1",
      "slug": "rtm-h8lTf3VyNUAenaRXGVWD"
    },
    {
      "username": "joeyorlando",
      "slug": "rtm-QIRzjSe3jyatvpIcutLt"
    }
  ]
}

We use this function on the start attribute. This shift is set to start at 17h (America/Toronto tz).. which is 21h UTC. With that said, I suppose I don't need to do dt.replace(tzinfo=datetime.timezone.utc)

"user_id": user_id,
"type": "wait",
"duration": transform_wait_delay(delay),
"important": False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, I guess there isn't a default/important distinction in Splunk, right? Are we leaving important policy empty then? Should allow some config to duplicate/default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, they have a concept called "custom paging policies", but those really don't map to how we model user notification policies, so I just decided to map Primary Paging Policy -> Default and ignore custom ones:

Screenshot 2024-05-14 at 09 24 47

(the PagerDuty migrator also hardcodes created user notification policies to "important": False)

@joeyorlando joeyorlando added this pull request to the merge queue May 14, 2024
Merged via the queue into dev with commit c46dff0 May 14, 2024
21 checks passed
@joeyorlando joeyorlando deleted the jorlando/splunk-migration-tool branch May 14, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:enhancement PR will be added to "Exciting New Features 🎉" section of release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants