Add LogType and Metadata for Log Analytics
This commit is contained in:
committed by
Robbie Zhang
parent
b41c1fee1a
commit
844d8a71d0
@@ -220,6 +220,16 @@ func NewACIProvider(config string, rm *manager.ResourceManager, nodeName, operat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if clusterResourceID := os.Getenv("CLUSTER_RESOURCE_ID"); clusterResourceID != "" {
|
||||||
|
if p.diagnostics != nil && p.diagnostics.LogAnalytics != nil {
|
||||||
|
p.diagnostics.LogAnalytics.LogType = aci.LogAnlyticsLogTypeContainerInsights
|
||||||
|
p.diagnostics.LogAnalytics.Metadata = map[string]string{
|
||||||
|
aci.LogAnalyticsMetadataKeyClusterResourceID: clusterResourceID,
|
||||||
|
aci.LogAnalyticsMetadataKeyNodeName: nodeName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if rg := os.Getenv("ACI_RESOURCE_GROUP"); rg != "" {
|
if rg := os.Getenv("ACI_RESOURCE_GROUP"); rg != "" {
|
||||||
p.resourceGroup = rg
|
p.resourceGroup = rg
|
||||||
}
|
}
|
||||||
@@ -654,6 +664,15 @@ func formDNSSearchFitsLimits(searches []string) string {
|
|||||||
return strings.Join(searches, " ")
|
return strings.Join(searches, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ACIProvider) getDiagnostics(pod *v1.Pod) *aci.ContainerGroupDiagnostics {
|
||||||
|
if p.diagnostics != nil && p.diagnostics.LogAnalytics != nil && p.diagnostics.LogAnalytics.LogType == aci.LogAnlyticsLogTypeContainerInsights {
|
||||||
|
d := *p.diagnostics
|
||||||
|
d.LogAnalytics.Metadata[aci.LogAnalyticsMetadataKeyPodUUID] = string(pod.ObjectMeta.UID)
|
||||||
|
return &d
|
||||||
|
}
|
||||||
|
return p.diagnostics
|
||||||
|
}
|
||||||
|
|
||||||
func containerGroupName(pod *v1.Pod) string {
|
func containerGroupName(pod *v1.Pod) string {
|
||||||
return fmt.Sprintf("%s-%s", pod.Namespace, pod.Name)
|
return fmt.Sprintf("%s-%s", pod.Namespace, pod.Name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,8 +340,10 @@ type ContainerGroupDiagnostics struct {
|
|||||||
|
|
||||||
// LogAnalyticsWorkspace defines details for a Log Analytics workspace
|
// LogAnalyticsWorkspace defines details for a Log Analytics workspace
|
||||||
type LogAnalyticsWorkspace struct {
|
type LogAnalyticsWorkspace struct {
|
||||||
WorkspaceID string `json:"workspaceID,omitempty"`
|
WorkspaceID string `json:"workspaceID,omitempty"`
|
||||||
WorkspaceKey string `json:"workspaceKey,omitempty"`
|
WorkspaceKey string `json:"workspaceKey,omitempty"`
|
||||||
|
LogType LogAnalyticsLogType `json:"logType,omitempty"`
|
||||||
|
Metadata map[string]string `json:"metadata,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerGroupMetricsResult stores all the results for a container group metrics request.
|
// ContainerGroupMetricsResult stores all the results for a container group metrics request.
|
||||||
@@ -470,3 +472,19 @@ type DNSConfig struct {
|
|||||||
SearchDomains string `json:"searchDomains,omitempty"`
|
SearchDomains string `json:"searchDomains,omitempty"`
|
||||||
Options string `json:"options,omitempty"`
|
Options string `json:"options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogAnalyticsLogType is an enum type for defining supported log analytics log types
|
||||||
|
type LogAnalyticsLogType string
|
||||||
|
|
||||||
|
// Supported log analytics log types
|
||||||
|
const (
|
||||||
|
LogAnlyticsLogTypeContainerInsights LogAnalyticsLogType = "ContainerInsights"
|
||||||
|
LogAnlyticsLogTypeContainerInstance LogAnalyticsLogType = "ContainerInstance"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Supported log analytics metadata keys
|
||||||
|
const (
|
||||||
|
LogAnalyticsMetadataKeyPodUUID string = "pod-uuid"
|
||||||
|
LogAnalyticsMetadataKeyNodeName string = "node-name"
|
||||||
|
LogAnalyticsMetadataKeyClusterResourceID string = "cluster-resource-id"
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user