apiVersion: v1
kind: ConfigMap
metadata:
name: appinsight
data:
APPINSIGHTS_INSTRUMENTATIONKEY:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image:
import com.microsoft.applicationinsights.TelemetryClient;
TelemetryClient telemetry = new TelemetryClient(); telemetry.getContext().setInstrumentationKey(System.getenv("APPINSIGHTS_INSTRUMENTATIONKEY"));
telemetry.trackEvent("my-event"); telemetry.trackTrace("my-trace"); telemetry.trackException(new Exception("my-exception"));
这些步骤将确保你的AKS pod在运行时将遥测数据发送到指定的ApplicationInsight中。
下一篇:AKS日志不显示时间戳