Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

feat(cli): add command to import KPIs from a JSON #557

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Samyak2
Copy link
Contributor

@Samyak2 Samyak2 commented Dec 29, 2021

Changes

The kpi-import command reads a JSON file given as input and adds all the KPIs in it. The JSON must have a list of KPIs in the specified format (similar to JSON of the API endpoint - some field names may differ).

If a KPI addition fails, it's logged and the script moves on to the next one.

@netlify
Copy link

netlify bot commented Dec 29, 2021

✔️ Deploy Preview for frontend-sb canceled.

🔨 Explore the source changes: e562d84

🔍 Inspect the deploy log: https://app.netlify.com/sites/frontend-sb/deploys/61e560d2523b06000739f7d5

chaos_genius/commands.py Outdated Show resolved Hide resolved
@Samyak2 Samyak2 added this to the v0.4.0 milestone Jan 4, 2022
The `kpi-import` command reads a JSON file given as input and adds all
the KPIs in it. The JSON must have a list of KPIs in the specified
format (similar to JSON of the API endpoint - some field names may
differ).

TODO: some of the code is repeated from the KPI endpoint.

If a KPI addition fails, it's logged and the script moves on to the next
one.
@Samyak2 Samyak2 added the don't merge PR which doesn't need to be merged right now label Jan 17, 2022
Added a generalized `add_kpi` function in kpi_controller.
- Handles validation, adding to dashboards, anomaly params validation
  and running analytics.
- validation and analytics run can be switched off.
- Split some unrelated parts into separate functions
    - `_kpi_query_strip_trailing_semicolon`
    - `_add_kpi_to_dashboards`
    - `queue_kpi_analytics` (added to anomaly_tasks.py)

Updated both the CLI and the KPI view to use this new function.

Tested by adding a simple KPI from the UI and importing a KPI from the
CLI.
@Samyak2 Samyak2 changed the base branch from main to develop January 17, 2022 12:28
@Samyak2 Samyak2 requested a review from manassolanki January 17, 2022 12:29
chaos_genius/commands.py Outdated Show resolved Hide resolved
chaos_genius/controllers/kpi_controller.py Outdated Show resolved Hide resolved
chaos_genius/jobs/anomaly_tasks.py Outdated Show resolved Hide resolved
Samyak2 and others added 2 commits January 17, 2022 18:10
Co-authored-by: Kartikay Bagla <kartikaybagla@gmail.com>
Co-authored-by: Kartikay Bagla <kartikaybagla@gmail.com>
`anomaly_task` will be None when anomaly doesn't need to run. We will
still log an error in that case, when there's actually no error.

Co-authored-by: Kartikay Bagla <kartikaybagla@gmail.com>
@Samyak2
Copy link
Contributor Author

Samyak2 commented Jan 17, 2022

I will be adding a data source import command to this same PR.

@Samyak2 Samyak2 modified the milestone: v0.4.0 Jan 28, 2022
@Samyak2 Samyak2 removed the don't merge PR which doesn't need to be merged right now label Jan 28, 2022
@Samyak2 Samyak2 removed this from the v0.4.0 milestone Jan 28, 2022
@manassolanki manassolanki added the don't merge PR which doesn't need to be merged right now label Jan 28, 2022
@varunp2k
Copy link
Member

varunp2k commented Apr 13, 2022

@kartikay-bagla @Samyak2 Any reason as to why we are not resolving conflicts and merging this?

@Samyak2 Samyak2 marked this pull request as draft June 28, 2022 03:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🛠️ backend don't merge PR which doesn't need to be merged right now
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants