Skip to content

feat: add HTML response handling for target allocator #3652

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

Merged
merged 9 commits into from
Jun 12, 2025

Conversation

CharlieTLe
Copy link
Contributor

@CharlieTLe CharlieTLe commented Jan 22, 2025

Description:
Adds support for HTML output in the target allocator.

Link to tracking Issue(s):

Testing:

Configured unit tests with golden files to test that HTML renders the correct response.

To start the test, run

make prepare-e2e

Setup a TA

# Sets up ClusterRole with full access to all resources and nonResourceURLs
# This is just for demonstration purposes and should not be used in production
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: ta
rules:
- apiGroups: [ '*' ]
  resources: [ '*' ]
  verbs: [ '*' ]
- nonResourceURLs: [ '*' ]
  verbs: [ '*' ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: ta
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: ta
subjects:
  - kind: ServiceAccount
    name: ta-targetallocator
    namespace: default
---
# Sets up the TargetAllocator
apiVersion: opentelemetry.io/v1alpha1
kind: TargetAllocator
metadata:
  name: ta
  namespace: default
spec:
  # Sets up the ServiceMonitor for the TA
  observability:
    metrics:
      enableMetrics: true
  # Set up watching of ServiceMonitors
  prometheusCR:
    enabled: true
    serviceMonitorSelector: {}

Port-forward to the TA pod.

kubectl port-forward -n default deploy/ta-targetallocator 8080:8080

Once port-forwarded, go to http://localhost:8080.

Screenshots:

Home

home

Scrape Configs

scrape_configs

Jobs

jobs

Targets

targets

Collector

collector

Job

job

Target

target

@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch from c9c6e2a to d6cb377 Compare January 23, 2025 02:45
@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch 2 times, most recently from 4fc7fa4 to 76cf475 Compare January 24, 2025 02:08
@CharlieTLe CharlieTLe marked this pull request as ready for review January 24, 2025 05:07
@CharlieTLe CharlieTLe requested a review from a team as a code owner January 24, 2025 05:07
Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

Changes look ok to me.

@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch from e7ca1d8 to b4f43e2 Compare March 16, 2025 21:05
@CharlieTLe CharlieTLe changed the title feat: add HTML response handling for job and target endpoints feat: add HTML response handling for target allocator Mar 16, 2025
@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch 2 times, most recently from 25d825d to d96300a Compare March 23, 2025 20:31
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

other than the path, i think everything looks great! thank you 🙇

@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch from f9264cd to 8e37185 Compare March 25, 2025 15:46
@chenlujjj
Copy link
Contributor

Is it ready to be merged?

@jaronoff97
Copy link
Contributor

@chenlujjj there's one conflict, otherwise yes

Signed-off-by: Charlie Le <charlie_le@apple.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
@CharlieTLe CharlieTLe force-pushed the otel-targetallocator-html branch from 8e37185 to bf30b81 Compare June 7, 2025 18:03
Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

I'm ok with merging this PR as-is, although I'd love it if the raw html could be removed from handler functions completely. Nonetheless, thank you for your work on this feature, it must've been a huge pain.

… to use dedicated HTML templates for bad requests and not found responses

Signed-off-by: Charlie Le <charlie_le@apple.com>
@swiatekm swiatekm merged commit eb8ebba into open-telemetry:main Jun 12, 2025
54 of 55 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.

UI for Jobs and Scrape Configs in Target Allocator Server
6 participants