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

Anomaly detection using Isolation Forest #41

Merged

Conversation

shashank-boyapally
Copy link
Contributor

Type of change

  • Refactor
  • New feature
  • Bug fix
  • Optimization
  • Documentation Update

Description

Support for anomaly detection added to orion, this allows the ability to add other algorithms as well. Below are the outputs of the anomaly detection run on small scale cdv2. It is to be noted that the deviation in percentage change reported is the change in percentage from the weighted mean over a window at that particular datapoint

(venv) sboyapal orion (anomaly-detection) >> orion cmd --anomaly-detection
2024-06-13 16:09:01,205 - Orion - INFO - file: orion.py - line: 76 - 🏹 Starting Orion in command-line mode
2024-06-13 16:09:01,207 - Orion - INFO - file: utils.py - line: 279 - The test aws-small-scale-cluster-density-v2 has started
2024-06-13 16:09:01,208 - Matcher - INFO - Executing query against index=ospst-perf-scale-ci-*
2024-06-13 16:09:02,108 - Matcher - INFO - Executing query against index=ospst-perf-scale-ci-*
2024-06-13 16:09:02,307 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:02,538 - Orion - INFO - file: utils.py - line: 122 - Collecting podReadyLatency
2024-06-13 16:09:02,538 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:02,761 - Orion - INFO - file: utils.py - line: 122 - Collecting apiserverCPU
2024-06-13 16:09:02,763 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:05,534 - Orion - INFO - file: utils.py - line: 122 - Collecting ovnCPU
2024-06-13 16:09:05,534 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:07,939 - Orion - INFO - file: utils.py - line: 122 - Collecting etcdCPU
2024-06-13 16:09:07,939 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:10,147 - Orion - INFO - file: utils.py - line: 122 - Collecting etcdDisk
2024-06-13 16:09:10,148 - Matcher - INFO - Executing query against index=ospst-ripsaw-kube-burner*
2024-06-13 16:09:15,180 - Orion - INFO - file: isolationForest.py - line: 49 - starting analysis
aws-small-scale-cluster-density-v2
==================================
uuid                                  timestamp                         podReadyLatency_P99    apiserverCPU_avg    ovnCPU_avg    etcdCPU_avg    etcdDisk_avg  buildUrl
------------------------------------  ------------------------------  ---------------------  ------------------  ------------  -------------  --------------  ----------------------------
e624b10f-148b-4871-acb5-e8a71cf1b605  2023-10-16T19:25:28.918376168Z                  13000            10.175         2.42737        7.63694       0.0115776  https://tinyurl.com/2aegbcer
325dd073-b680-4e44-951f-26506f401be0  2023-10-18T15:11:43.099695069Z                  13000            10.4876        2.49018        8.12781       0.0107434  https://tinyurl.com/25oa4d6a
8cfc4fcf-46c7-4b9f-a464-cd100bfb84bf  2023-10-24T10:52:22.56500282Z                   13000            10.3932        2.44498        7.60968       0.0116801  https://tinyurl.com/26ggbhzk
3c9e2789-59d4-4d6f-9f07-5c400cf25c93  2023-10-31T10:30:02.883219507Z                  13000            11.0129        2.73347        8.83458       0.0112971  https://tinyurl.com/23jfdvnx
649228fb-9ff4-458a-8a8b-b9ecb521ca1b  2023-11-03T04:08:14.153312504Z                  13000            10.8605        2.82005        8.34146       0.0101805  https://tinyurl.com/2bd77bxn
                                                                      ·····················                                    ·············  ··············                                
                                                                                     +11.9%                                            -7.3%          +10.7%                                
                                                                      ·····················                                    ·············  ··············                                
d8e0c965-4548-48d4-8a7a-c065b93ee766  2023-11-07T10:26:08.157079492Z                  15000            10.5964        2.6356         7.48679       0.0124896  https://tinyurl.com/2am6wmqz
a990f7f9-1faf-41f7-b9fb-3b83f91b6e52  2023-11-15T12:36:38.590463149Z                  13000            10.8222        2.81836        8.56302       0.0112316  https://tinyurl.com/2dcczlfd
e6c219dc-a9aa-4cf9-854a-fbd846c8ad22  2023-11-22T12:53:45.415024477Z                  13000            10.8555        2.84967        8.20129       0.0111251  https://tinyurl.com/28eyzgpm
adc95590-791d-423b-9d09-8190178edbf6  2023-11-29T12:32:04.399865722Z                  13000            11.4115        2.8615         8.67125       0.0127318  https://tinyurl.com/2yyz29x9
5b06c830-be55-4c84-b4da-92720b55c304  2023-12-06T12:34:57.789957283Z                  13000            11.05          2.85996        8.69638       0.0134358  https://tinyurl.com/2ym443kz
c5f95336-27d4-4615-94c1-d618e975a36b  2023-12-20T12:37:17.853113399Z                  13000            10.9253        2.77954        8.20148       0.0137848  https://tinyurl.com/28tfs4g4
bd5e6cad-6bc2-472d-948a-b1fbb350e80a  2023-12-27T12:36:59.93038097Z                   13000            11.1967        2.77645        8.63235       0.0154012  https://tinyurl.com/2ce2rhwx
b91c7156-0b86-4c79-81eb-60dfb7288070  2024-01-03T12:33:09.296851062Z                  13000            10.7863        2.80557        8.54677       0.0138396  https://tinyurl.com/25yft84a
12a1750e-a7eb-48ed-bc00-35078d2bbad8  2024-01-10T12:38:16.41007845Z                   13000            10.9379        3.10667        8.86329       0.0154639  https://tinyurl.com/28pv78qv
c6b4aaa3-cd2c-4f04-af20-3d10c52449a2  2024-01-10T22:59:25.227786493Z                  13000            11.4162        3.1338         9.29143       0.0128269  https://tinyurl.com/2dxn4kcx
                                                                                             ··················  ············  ·············                                                
                                                                                                         +33.5%        +21.9%         +11.3%                                                
                                                                                             ··················  ············  ·············                                                
c2963cec-e800-423f-92b1-3e6f692a55cb  2024-01-11T17:30:26.671046369Z                  13000            16.1465        3.80976       10.1149        0.0149901  https://tinyurl.com/254ypbj7
4f73a079-0088-4027-af0d-7c1b5b429fdd  2024-01-15T13:01:36.654707349Z                  13000            15.0479        3.93557       10.0966        0.0193588  https://tinyurl.com/22x8v7j5
90189fbf-7181-4129-8ca5-3cc8d656b595  2024-01-15T20:30:57.858188551Z                  13000            10.8181        3.05989        8.48998       0.015606   https://tinyurl.com/2cucdsre
                                                                      ·····················  ··················  ············                 ··············                                
                                                                                      +6.1%              -12.7%        -10.6%                         -17.2%                                
                                                                      ·····················  ··················  ············                 ··············                                
bff92096-3a8e-4cb4-805b-55638be4aa23  2024-01-17T12:35:28.689492795Z                  14000            11.3023        3.03366        9.04686       0.0124663  https://tinyurl.com/2yl8rdfj
                                                                                             ··················  ············  ·············  ··············                                
                                                                                                         +15.8%        +10.7%          +9.3%          +35.4%                                
                                                                                             ··················  ············  ·············  ··············                                
f8778f71-08b3-42af-8e71-6ce1b8335c8d  2024-01-22T12:57:43.18850164Z                   13000            16.0607        3.93435       10.5545        0.0231879  https://tinyurl.com/2djm23ol
d70a8864-b251-417a-b43b-d85a54604c0f  2024-01-24T12:48:41.180747771Z                  13000            10.7205        3.05           8.23406       0.015117   https://tinyurl.com/2cwo7z83
28175f25-7f08-4b86-b754-cca0a59f35ea  2024-01-29T16:41:22.030281357Z                  13000            15.5962        3.93055       10.1279        0.0215355  https://tinyurl.com/2yw6j3cv
33feb742-30be-45c4-9849-52072e52aaee  2024-01-31T12:41:55.762603033Z                  13000            11.1809        3.0081         9.01858       0.0164261  https://tinyurl.com/2a64fpwc
                                                                                             ··················  ············  ·············  ··············                                
                                                                                                         +17.1%        +13.4%          +8.1%          +11.0%                                
                                                                                             ··················  ············  ·············  ··············                                
ab482da1-a857-4d08-948a-897d9c670b64  2024-02-05T12:57:47.32596161Z                   13000            16.3836        4.08402       10.4616        0.0217523  https://tinyurl.com/2c7xdgox
724504bf-637b-407b-b379-d46614df9da5  2024-02-07T12:48:05.86580952Z                   13000            10.8264        3.09103        8.57438       0.0149923  https://tinyurl.com/288mnsrk
69475c18-ad94-4a34-b6c1-f7d4d5b2043a  2024-02-07T13:26:27.239666048Z                  13000            10.9693        3.11466        8.77954       0.0147759  https://tinyurl.com/29r4bvsq
f728b48b-96a6-49b8-8bdf-06f71b0b0108  2024-02-12T12:58:13.370813818Z                  13000            15.3591        3.95375       10.3827        0.0196659  https://tinyurl.com/29k9xbmy
                                                                      ·····················  ··················  ············  ·············                                                
                                                                                     +11.9%              -17.4%        -11.8%         -14.6%                                                
                                                                      ·····················  ··················  ············  ·············                                                
11ad8eda-d216-459c-b7c0-074ae3f9985f  2024-02-14T12:43:09.661131104Z                  15000            10.6023        3.04942        7.87127       0.0167123  https://tinyurl.com/253v4wk9
57047431-b1c2-4b92-8a73-5ab9748e36cd  2024-02-14T13:14:31.149423284Z                  13000            10.917         3.12045        9.07447       0.0153045  https://tinyurl.com/2xlfjang
016e4661-592d-4b73-a37f-87af72525304  2024-02-19T12:50:58.373528785Z                  13000            15.2763        3.79274       10.3673        0.0187124  https://tinyurl.com/257caq75
06510f77-8045-4794-b039-931b863881eb  2024-02-21T02:23:44.720041206Z                  13000            10.8696        3.08519        8.83996       0.0139078  https://tinyurl.com/2cu5beq6
40bb717d-c6b8-4849-a35d-5cf9827c0f87  2024-02-21T12:38:34.465272255Z                  13000            11.5674        3.18467        9.05926       0.0138407  https://tinyurl.com/2ycjbmep
1a8fafdf-d708-4b74-bc6d-25e53fd794e5  2024-02-26T12:53:57.896310519Z                  13000            15.18          3.7643        10.1673        0.0207603  https://tinyurl.com/26pugjpf
5618ae26-9834-446b-a11d-325904dea11f  2024-02-28T02:18:15.448393025Z                  13000            11.1215        3.12227        8.77388       0.0148055  https://tinyurl.com/27r78lq8
86d23106-3d61-4d17-9ccb-e63335aa4e87  2024-02-28T12:42:08.536897152Z                  13000            11.1699        3.07155        8.75668       0.0154707  https://tinyurl.com/28vv6hdu
64c18082-a176-4caf-943c-b5b9510fa6f7  2024-03-04T13:00:24.786634709Z                  13000            15.4869        3.758          9.76461       0.0169665  https://tinyurl.com/22ha9z2e
c2bfe27e-2c4d-4fc8-9790-d1092097b892  2024-03-11T13:01:55.667689333Z                  13000            14.315         3.72252        9.14236       0.018497   https://tinyurl.com/2737yxj3
42f559ac-d84c-4863-aa50-36d53861bea2  2024-03-18T12:57:13.430729195Z                  13000            13.8285        3.75282        9.10371       0.0212574  https://tinyurl.com/2d2dlc74
3ebd29d8-8f5e-4d37-9980-92e1df9b23d5  2024-03-25T13:02:24.432852939Z                  13000            14.0717        3.39056        8.79218       0.0199836  https://tinyurl.com/2cerjhjs
41bc479f-a537-4064-a3f5-cd90487b88ec  2024-04-01T12:57:39.416937133Z                  13000            14.0113        3.40633        9.23566       0.0204199  https://tinyurl.com/26pdc7pg
299055ad-e11d-4453-ba53-ef6d3a4fbe66  2024-04-08T12:54:32.05264333Z                   13000            13.4751        3.27225        8.37863       0.0180426  https://tinyurl.com/2ddrolqc
738959ff-d6b1-4deb-accf-accbb9c4b44b  2024-04-15T13:00:43.74776325Z                   13000            14.1985        3.29145        8.49561       0.0188224  https://tinyurl.com/22y97cre
50042d92-6beb-4504-bf09-3962c7d46a69  2024-04-22T13:01:26.374748377Z                  13000            13.846         3.39665        8.71211       0.0145549  https://tinyurl.com/28r6ltn6
68654663-76b1-4e15-876f-611cea0c90e6  2024-04-23T19:58:45.925131708Z                  13000            14.6744        3.34002        9.51948       0.014863   https://tinyurl.com/2a2h2l6u
ab49e179-02ae-4c6d-91ed-20a21dd7a85a  2024-04-29T13:14:38.471583105Z                  13000            14.3257        3.48515        9.53238       0.0146182  https://tinyurl.com/2646dxah
2edcbdfe-53b3-4a84-a397-5ba570cd2f42  2024-05-06T10:16:38.306402256Z                  13000            13.8513        3.39787        8.98409       0.0159737  https://tinyurl.com/25kygwa4
48bd2a91-23be-41c8-9ee9-ace2983bd759  2024-05-06T13:00:14.264688227Z                  13000            13.6255        3.35232        9.09342       0.0165254  https://tinyurl.com/2xr9dtjn
0b971494-30ba-41b2-996b-2bff9d976f91  2024-05-06T16:10:27.404087598Z                  13000            13.7244        3.30442        8.8804        0.0180565  https://tinyurl.com/25zaujx6
095bf4f9-4179-4f4f-af59-3f7c567d4997  2024-05-20T13:00:40.119357598Z                  13000            14.2495        3.4731         9.43963       0.0196035  https://tinyurl.com/286wm7dw
                                                                                                                                              ··············                                
                                                                                                                                                      +28.2%                                
                                                                                                                                              ··············                                
23d5432c-c746-4b64-8f94-c1b94d4df21a  2024-05-24T01:08:09.409217217Z                  13000            13.8248        3.40533        9.38661       0.0242031  https://tinyurl.com/2ahu4bfy
88265722-3415-4838-bd7a-f68534039d48  2024-06-03T01:01:57.99836556Z                   13000            12.4627        3.11514        8.35          0.0144284  https://tinyurl.com/2cfjqasa
                                                                                             ··················                ·············                                                
                                                                                                         -25.6%                       -15.0%                                                
                                                                                             ··················                ·············                                                
ede95b10-0473-4a21-9f66-64248b1f5db2  2024-06-09T13:39:58.639722136Z                  13000             9.48918       3.34431        7.38031       0.0187562  https://tinyurl.com/23sgr743
                                                                                             ··················                ·············  ··············                                
                                                                                                         -19.2%                       -12.9%          -12.6%                                
                                                                                             ··················                ·············  ··············                                
f8a46511-9873-46ef-816d-83c8f5047902  2024-06-09T16:12:41.690965253Z                  13000             9.64707       3.39072        7.29316       0.0163114  https://tinyurl.com/27d3qkjw
4e31afc5-0b81-4520-aa82-8b672cbe7f72  2024-06-10T01:07:17.88350307Z                   13000            14.3199        3.34758        8.94226       0.019336   https://tinyurl.com/2a6nzcsn

Similarly in daemon mode one can now reach out to the endpoint daemon/anomaly below is the sample output of a json list

{
            "uuid": "f8a46511-9873-46ef-816d-83c8f5047902",
            "timestamp": "2024-06-09T16:12:41.690965253Z",
            "buildUrl": "https://tinyurl.com/27d3qkjw",
            "metrics": {
                "podReadyLatency_P99": {
                    "value": 13000,
                    "percentage_change": 0.0
                },
                "etcdCPU_avg": {
                    "value": 7.2931611809,
                    "percentage_change": -12.86487277992999
                },
                "etcdDisk_avg": {
                    "value": 0.0163114135,
                    "percentage_change": -12.588628262126674
                },
                "ovnCPU_avg": {
                    "value": 3.3907244912,
                    "percentage_change": 0.0
                },
                "apiserverCPU_avg": {
                    "value": 9.6470740628,
                    "percentage_change": -19.16743869817369
                }
            },
            "is_anomalypoint": true
}

It is to be noted that the endpoint to changepoint is now moved to daemon/changepoint from /daemon

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please describe the System Under Test.
  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
pkg/isolationForest.py Outdated Show resolved Hide resolved
pkg/isolationForest.py Outdated Show resolved Hide resolved
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
README.md Outdated Show resolved Hide resolved
@shashank-boyapally shashank-boyapally mentioned this pull request Jun 24, 2024
7 tasks
pkg/daemon.py Outdated Show resolved Hide resolved
orion.py Outdated Show resolved Hide resolved
orion.py Outdated Show resolved Hide resolved
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
orion.py Show resolved Hide resolved
pkg/types.py Outdated Show resolved Hide resolved
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
"config": config_file_name,
"output_path": "output.csv",
"hunter_analyze": True,
"output_format": "json",
"anomaly_detection": False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While we already have hunter_analyze to indicate that this is related to change point detection, do we need anamaly_detection as an argument here? Vice versa applies to the endpoint /daemon/anomaly too.



def run(**kwargs):
Copy link
Collaborator

@vishnuchalla vishnuchalla Jun 26, 2024

Choose a reason for hiding this comment

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

@shashank-boyapally Is there a specific reason we have replace **kwargs with the OptionMap? OptionMap doesn't seem to be required. We can achieve thread safety in both if that is our primary concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why we are going ahead with OptionMap structure instead of kwargs is, some of the options are being used across other functions such as the anomaly window for anomaly detection. For cleaner code it was better to call OptionMap instead of passing kwargs throughout.

dataframe_json = self.dataframe.to_json(orient="records")
dataframe_json = json.loads(dataframe_json)

for index, entry in enumerate(dataframe_json):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was just thinking if we can abstract out these structure that give us only a list of changepoints and the full list of json. As they can reused by any model integration. @shashank-boyapally any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be adding this to in follow-on PR

Copy link
Member

Choose a reason for hiding this comment

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

Can we convert this comment into an RFE issue? So we don't lose track

@vishnuchalla
Copy link
Collaborator

@shashank-boyapally nice addition. Can we think of a better directory structure by grouping things into multiple packages like having all the algos at one place and the rest categorized as well? That way we won't end up having everything in the root directory.

@jtaleric
Copy link
Member

@shashank-boyapally nice addition. Can we think of a better directory structure by grouping things into multiple packages like having all the algos at one place and the rest categorized as well? That way we won't end up having everything in the root directory.

Could we introduce a new structure in a follow on PR @vishnuchalla ?

@jtaleric
Copy link
Member

lgtm! Tested locally. Address any concerns @vishnuchalla has.

@jtaleric jtaleric self-requested a review June 26, 2024 15:47
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
Copy link
Collaborator

@vishnuchalla vishnuchalla left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@paigerube14 paigerube14 left a comment

Choose a reason for hiding this comment

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

LGTM

@vishnuchalla vishnuchalla merged commit fe23a8f into cloud-bulldozer:main Jun 27, 2024
2 checks passed
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.

4 participants