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

[newrelic-logging] Allow setting a custom metrics endpoint to bypass the broken autodetection #1450

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

giannello
Copy link
Contributor

@giannello giannello commented Aug 2, 2024

Is this a new chart

No

What this PR does / why we need it:

Allows overriding the default metrics endpoint, as it's already possible for the logs endpoint

Which issue this PR fixes

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [mychartname])

@giannello giannello requested a review from a team as a code owner August 2, 2024 14:41
@CLAassistant
Copy link

CLAassistant commented Aug 2, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@nr-rkallempudi nr-rkallempudi left a comment

Choose a reason for hiding this comment

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

Code changes looks good. Can you please add unit tests in file: endpoint_region_selection_test.yaml

I am sharing few tests in addition to the existing ones. You can add more cases if you see the need. Add these tests to commit. If you want us to add the tests, we can add it from our side.

templates:
  - templates/configmap.yaml
  - templates/daemonset.yaml
  - templates/daemonset-windows.yaml
release:
  name: endpoint-selection-release
  namespace: endpoint-selection-namespace
tests:

  - it: selects staging endpoints if nrStaging is enabled
    set:
      licenseKey: nr_license_key
      nrStaging: true
      enableWindows: true
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://staging-log-api.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "staging-metric-api.newrelic.com"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://staging-log-api.newrelic.com/log/v1"
        template: templates/daemonset-windows.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "staging-metric-api.newrelic.com"
        template: templates/daemonset-windows.yaml

  - it: selects US endpoints for a US license key
    set:
      licenseKey: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
      enableWindows: true
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.newrelic.com"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.newrelic.com/log/v1"
        template: templates/daemonset-windows.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.newrelic.com"
        template: templates/daemonset-windows.yaml
  
  - it: selects EU endpoints for a EU license key
    set:
      licenseKey: euaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
      enableWindows: true
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.eu.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.eu.newrelic.com"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.eu.newrelic.com/log/v1"
        template: templates/daemonset-windows.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.eu.newrelic.com"
        template: templates/daemonset-windows.yaml


  - it: selects custom logs endpoint if provided
    set:
      licenseKey: euaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
      endpoint: custom
      enableWindows: true
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "custom"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "custom"
        template: templates/daemonset-windows.yaml

  - it: selects user defined endpoint
    set:
      licenseKey: nr_license_key
      nrStaging: false
      enableWindows: true
      metricsEndpoint: "https://user-defined-api.newrelic.com"
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "https://user-defined-api.newrelic.com"
        template: templates/daemonset.yaml
     
  - it: selects user-defined metrics endpoint even with EU license key
    set:
      licenseKey: euaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
      enableWindows: true
      metricsEndpoint: "https://user-defined-eu-metric-api.newrelic.com"
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.eu.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "https://user-defined-eu-metric-api.newrelic.com"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.eu.newrelic.com/log/v1"
        template: templates/daemonset-windows.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "https://user-defined-eu-metric-api.newrelic.com"
        template: templates/daemonset-windows.yaml

  - it: selects default US metrics endpoint when metricsEndpoint is not provided and license key is not EU
    set:
      licenseKey: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
      enableWindows: true
    asserts:
      # Linux
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.newrelic.com/log/v1"
        template: templates/daemonset.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.newrelic.com"
        template: templates/daemonset.yaml
      # Windows
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ENDPOINT
            value: "https://log-api.newrelic.com/log/v1"
        template: templates/daemonset-windows.yaml
      - contains:
          path: spec.template.spec.containers[0].env
          content:
            name: METRICS_HOST
            value: "metric-api.newrelic.com"
        template: templates/daemonset-windows.yaml ```

hrai-nr
hrai-nr previously approved these changes Nov 5, 2024
@voorepreethi voorepreethi dismissed nr-rkallempudi’s stale review November 7, 2024 09:13

test cases Added in a new PR

@voorepreethi voorepreethi merged commit 79abdb3 into newrelic:master Nov 7, 2024
10 checks passed
@giannello giannello deleted the patch-2 branch November 8, 2024 12:53
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.

[newrelic-logging] Metrics host magic in _helpers.tpl relies on plain value secret to choose EU over US
5 participants