Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ spec:
{{- end }}
- name: ISTEST
value: {{ .Values.omsagent.ISTEST | quote }}
{{ if .Values.omsagent.isArcACluster }}
- name: IS_ARCA_CLUSTER
value: {{ .Values.omsagent.isArcACluster | quote }}
{{- end }}
{{- if ne .Values.omsagent.metricsEndpoint "<your_metrics_endpoint>" }}
- name: CUSTOM_METRICS_ENDPOINT
value: {{ .Values.omsagent.metricsEndpoint | quote }}
{{- end }}
securityContext:
privileged: true
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ spec:
value: {{ .Values.omsagent.sidecarscraping | quote }}
- name: ISTEST
value: {{ .Values.omsagent.ISTEST | quote }}
{{ if .Values.omsagent.isArcACluster }}
- name: IS_ARCA_CLUSTER
value: {{ .Values.omsagent.isArcACluster | quote }}
{{- end }}
{{- if ne .Values.omsagent.metricsEndpoint "<your_metrics_endpoint>" }}
- name: CUSTOM_METRICS_ENDPOINT
value: {{ .Values.omsagent.metricsEndpoint | quote }}
{{- end }}
securityContext:
privileged: true
ports:
Expand Down
5 changes: 5 additions & 0 deletions charts/azuremonitor-containers/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ omsagent:
# This flag used to determine whether to use AAD MSI auth or not for Arc K8s cluster
useAADAuth: false

# This flag used to determine whether this cluster is connected to ArcA control plane. This value will be setup before pushed into on-premise ArcA ACR.
isArcACluster: false

## To get your workspace id and key do the following
## You can create a Azure Loganalytics workspace from portal.azure.com and get its ID & PRIMARY KEY from 'Advanced Settings' tab in the Ux.

Expand All @@ -57,6 +60,8 @@ omsagent:
key: <your_workspace_key>
domain: opinsights.azure.com
proxy: <your_proxy_config>
# This metricsEndpoint used to define the endpoint custom metrics emit to. If not defined, default public Azure monitoring endpoint '{aks_region}.monitoring.azure.com' will be used.
metricsEndpoint: <your_metrics_endpoint>
env:
clusterName: <your_cluster_name>
## Applicable for only managed clusters hosted in Azure
Expand Down
5 changes: 5 additions & 0 deletions source/plugins/ruby/CustomMetricsUtils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def check_custom_metrics_availability
if aks_region.to_s.empty? || aks_resource_id.to_s.empty?
return false # This will also take care of AKS-Engine Scenario. AKS_REGION/AKS_RESOURCE_ID is not set for AKS-Engine. Only ACS_RESOURCE_NAME is set
end
# If this is cluster is connected to ArcA control plane and metrics endpoint provided, custom metrics shall be emitted.
is_arca_cluster = ENV['IS_ARCA_CLUSTER']
if is_arca_cluster.to_s.downcase == "true" && !ENV['CUSTOM_METRICS_ENDPOINT'].to_s.empty?
return true
end

return aks_cloud_environment.to_s.downcase == 'azurepubliccloud'
end
Expand Down
14 changes: 12 additions & 2 deletions source/plugins/ruby/out_mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def initialize
@@token_resource_audience = "https://monitor.azure.com/"
@@grant_type = "client_credentials"
@@azure_json_path = "/etc/kubernetes/host/azure.json"
@@post_request_url_template = "https://%{aks_region}.monitoring.azure.com%{aks_resource_id}/metrics"
@@public_metrics_endpoint_template = "https://%{aks_region}.monitoring.azure.com"
@@post_request_url_template = "%{metrics_endpoint}%{aks_resource_id}/metrics"
@@aad_token_url_template = "https://login.microsoftonline.com/%{tenant_id}/oauth2/token"

# msiEndpoint is the well known endpoint for getting MSI authentications tokens
Expand Down Expand Up @@ -98,7 +99,16 @@ def start
if aks_resource_id.downcase.include?("microsoft.kubernetes/connectedclusters")
@isArcK8sCluster = true
end
@@post_request_url = @@post_request_url_template % { aks_region: aks_region, aks_resource_id: aks_resource_id }

# If CUSTOM_METRICS_ENDPOINT provided, the url format shall be validated before emitting metrics into given endpoint.
custom_metrics_endpoint = ENV['CUSTOM_METRICS_ENDPOINT']
if !custom_metrics_endpoint.to_s.empty?
metrics_endpoint = custom_metrics_endpoint.strip
URI.parse(metrics_endpoint)
else
metrics_endpoint = @@public_metrics_endpoint_template % { aks_region: aks_region }
end
@@post_request_url = @@post_request_url_template % { metrics_endpoint: metrics_endpoint, aks_resource_id: aks_resource_id }
@post_request_uri = URI.parse(@@post_request_url)
proxy = (ProxyUtils.getProxyConfiguration)
if proxy.nil? || proxy.empty?
Expand Down