Skip to content

enhancement to parse_html#378

Open
haihongren wants to merge 11 commits into
masterfrom
hren/html_parse
Open

enhancement to parse_html#378
haihongren wants to merge 11 commits into
masterfrom
hren/html_parse

Conversation

@haihongren

@haihongren haihongren commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

enhancement

  • added parse_html_attributes function to allow html element attribute to be parsed and included in the value, for example: class of the element

Use case
Google cloud service status web site uses class to show the status of the service.
https://status.cloud.google.com/

Working Example: GCP status

integrations:
  - name: nri-flex
    config:
      name: gcpStatus
      apis:
        - name: gcpStatus
          event_type: gcpStatus
          url: https://status.cloud.google.com/
          parse_html: true
          parse_html_attributes: 
            class: .*
          
          remove_keys: 
            - class
            - style
            - index
          
          value_mapper:
            Americas  regions:
                - (__cell;$)=>N/A
                - (.*__available;.*)=>Normal
                - (.*__information;.*)=>Info         
                - (.*__warning;.*)=>Warning
            Asia Pacific  regions:
                - (__cell;$)=>N/A
                - (.*__available;.*)=>Normal
                - (.*__information;.*)=>Info
                - (.*__warning;.*)=>Warning                                 
            Europe  regions:
                - (__cell;$)=>N/A
                - (.*__available;.*)=>Normal
                - (.*__information;.*)=>Info    
                - (.*__warning;.*)=>Warning                              
            Global:
                - (__cell;$)=>N/A
                - (.*__available;.*)=>Normal   
                - (.*__information;.*)=>Info    
                - (.*__warning;.*)=>Warning                                                                           
            Multi regions:
                - (__cell;$)=>N/A
                - (.*__available;.*)=>Normal 
                - (.*__information;.*)=>Info  
                - (.*__warning;.*)=>Warning                                 
            Products: 
                - (.*;)(.*)=>$2                                                            

haihongren and others added 5 commits August 29, 2022 10:13
# this flex integrations presumes you've installed the OKLA speedtest command line utility
# https://www.speedtest.net/apps/cli
# also make sure you update the  "run: sudo speedtest" command with the path to the utility
Co-authored-by: Kav. Pather <kav.pather@gmail.com>
@haihongren haihongren requested a review from Kav91 September 12, 2022 23:33
@davidgit davidgit added the hero label Sep 13, 2022
@davidgit davidgit requested a review from a team September 13, 2022 14:16
@rogercoll

Copy link
Copy Markdown
Contributor

Hi @haihongren ,

Could you add some end-to-end tests in https://github.com/newrelic/nri-flex/tree/master/test/testbed that cover this use case?
In addition, could you sign the commits?

Thanks for the contribution!

Signed-off-by: haihongren <haihong.ren@gmail.com>
@haihongren

Copy link
Copy Markdown
Contributor Author

@rogercoll thanks for the comments.
I have added e2e test for parse_html_attributes and also signed the commit.
The added e2e test passed.

    --- PASS: TestUrlAPI/html_parse_attributes_parse_html_attributes (0.03s)

The two failed e2e tests are not from my changes. Thanks!

    --- FAIL: TestCommandAPI/Linux_file_list_of_the_/etc/apt_directory_removing_header (0.03s)
    --- FAIL: TestCommandAPI/Linux_file_list_of_the_/etc/apt_directory_filtering_lines (0.03s)

@Kav91 Kav91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM nice 👍🏾

@Kav91 Kav91 requested a review from rogercoll January 18, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants