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

Suport jsonBody for web metric provider #2275

Closed
zachaller opened this issue Sep 29, 2022 · 3 comments
Closed

Suport jsonBody for web metric provider #2275

zachaller opened this issue Sep 29, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@zachaller
Copy link
Collaborator

zachaller commented Sep 29, 2022

Summary

Add support to web metric provider to make posting json easier. We would do this by adding a new field called jsonBody.

Today in order to post json to a web metric provider to POST data you end up with a metric configuration like this

metrics:
  - name: webmetric
    successCondition: result == true
    provider:
      web:
        method: POST # valid values are GET|POST|PUT, defaults to GET
        url: "http://my-server.com/api/v1/measurement?service={{ args.service-name }}"
        timeoutSeconds: 20 # defaults to 10 seconds
        headers:
          - key: Authorization
            value: "Bearer {{ args.api-token }}"
          - key: Content-Type # if body is a json, it is recommended to set the Content-Type
            value: "application/json"
        body: "{\"key\": \"string value\"}"
        jsonPath: "{$.data.ok}"

The body field being just a string that gets posted as the body in the http request.

I propose to add something like jsonBody which would make constructing json payloads cleaner

metrics:
  - name: webmetric
    successCondition: result == true
    provider:
      web:
        method: POST # valid values are GET|POST|PUT, defaults to GET
        url: "http://my-server.com/api/v1/measurement?service={{ args.service-name }}"
        timeoutSeconds: 20 # defaults to 10 seconds
        headers:
          - key: Authorization
            value: "Bearer {{ args.api-token }}"
          - key: Content-Type # if body is a json, it is recommended to set the Content-Type
            value: "application/json"
        jsonBody:  # If using jsonBody we could also auto set Content-Type headers
          key1: value_1
          key2:
            nestedObj: nested value
            key3: {{ args.api-token }}
        jsonPath: "{$.data.ok}"

I am not sure if today we support parsing templated args into body or not but it would be very valuable to do that if we do not as well.

Use Cases

When would you use this?


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritize the issues with the most 👍.

@zachaller zachaller added enhancement New feature or request hacktoberfest good first issue Good for newcomers labels Sep 29, 2022
@premadk
Copy link
Contributor

premadk commented Oct 5, 2022

Hi, I am new to Argo Rollouts. As a beginner, I think this enhancement fits well for me. Can I contribute on this? Thanks!

@zachaller
Copy link
Collaborator Author

Yes you can work on this, and thank you for contributing!

@premadk
Copy link
Contributor

premadk commented Oct 7, 2022

Thanks @zachaller Here is the PR #2301

jenciso pushed a commit to jenciso/argo-rollouts that referenced this issue Oct 25, 2022
…rgoproj#2275 (argoproj#2312)

* fix(issue2275): Support jsonBody for web metric provider

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

* fix(webmetrics): generate proto files

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

Signed-off-by: Prema devi Kuppuswamy <[email protected]>
jandersen-plaid pushed a commit to jandersen-plaid/argo-rollouts that referenced this issue Nov 8, 2022
…rgoproj#2275 (argoproj#2312)

* fix(issue2275): Support jsonBody for web metric provider

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

* fix(webmetrics): generate proto files

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

Signed-off-by: Prema devi Kuppuswamy <[email protected]>
jandersen-plaid pushed a commit to jandersen-plaid/argo-rollouts that referenced this issue Nov 26, 2022
…rgoproj#2275 (argoproj#2312)

* fix(issue2275): Support jsonBody for web metric provider

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

* fix(webmetrics): generate proto files

Signed-off-by: Prema devi Kuppuswamy <[email protected]>

Signed-off-by: Prema devi Kuppuswamy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants