@@ -4,6 +4,7 @@ import * as yaml from "js-yaml";
4
4
import * as path from "path" ;
5
5
import { dirSync } from "tmp" ;
6
6
import { AuthenticationSession , QuickPickItem , authentication , window } from "vscode" ;
7
+ import * as vscode from "vscode" ;
7
8
import {
8
9
API ,
9
10
APIAvailable ,
@@ -17,14 +18,15 @@ import { getTokenInfo } from "../../auth/azureAuth";
17
18
import { ReadyAzureSessionProvider , TokenInfo } from "../../auth/types" ;
18
19
import { AksClusterTreeNode } from "../../tree/aksClusterTreeItem" ;
19
20
import { SubscriptionTreeNode , isSubscriptionTreeNode } from "../../tree/subscriptionTreeItem" ;
20
- import { getAksClient } from "./arm" ;
21
+ import { getAksClient , getMonitorClient } from "./arm" ;
21
22
import { Errorable , map as errmap , failed , getErrorMessage , succeeded } from "./errorable" ;
22
23
import { getKubeloginBinaryPath } from "./helper/kubeloginDownload" ;
23
24
import { longRunning } from "./host" ;
24
25
import { invokeKubectlCommand } from "./kubectl" ;
25
26
import { withOptionalTempFile } from "./tempfile" ;
26
27
import { getResources } from "./azureResources" ;
27
28
import { ClusterFilter } from "./config" ;
29
+ import { DiagnosticSettingsResourceCollection } from "@azure/arm-monitor" ;
28
30
29
31
export interface KubernetesClusterInfo {
30
32
readonly name : string ;
@@ -678,3 +680,19 @@ export async function getClusters(
678
680
} ;
679
681
} ) ;
680
682
}
683
+
684
+ export async function getClusterDiagnosticSettings (
685
+ sessionProvider : ReadyAzureSessionProvider ,
686
+ clusterNode : AksClusterTreeNode ,
687
+ ) : Promise < DiagnosticSettingsResourceCollection | undefined > {
688
+ try {
689
+ // Get diagnostic setting via diagnostic monitor
690
+ const client = getMonitorClient ( sessionProvider , clusterNode . subscriptionId ) ;
691
+ const diagnosticSettings = await client . diagnosticSettings . list ( clusterNode . armId ) ;
692
+
693
+ return diagnosticSettings ;
694
+ } catch ( e ) {
695
+ vscode . window . showErrorMessage ( `Error fetching cluster diagnostic settings: ${ e } ` ) ;
696
+ return undefined ;
697
+ }
698
+ }
0 commit comments