Skip to content

Commit f7dc6b3

Browse files
bobsiraBob Sira
authored andcommitted
feat(aks/iis): add iis-logmonitor AKS example and docs
1 parent 99770f8 commit f7dc6b3

File tree

16 files changed

+827
-63
lines changed

16 files changed

+827
-63
lines changed

LogMonitor/docs/README.md

Lines changed: 166 additions & 63 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# escape=`
2+
FROM mcr.microsoft.com/windows/servercore:ltsc2022
3+
WORKDIR /LogMonitor
4+
COPY LogMonitorConfig.json .
5+
6+
# NOTE: replace the version (v2.1.3) in the URL below with the latest
7+
# LogMonitor release or with the specific version/build you want to use.
8+
RUN powershell.exe -command `
9+
wget `
10+
-uri "https://github.com/microsoft/windows-container-tools/releases/download/v2.1.3/LogMonitor.exe" `
11+
-outfile "LogMonitor.exe"
12+
13+
RUN powershell -Command `
14+
Add-WindowsFeature Web-Server; `
15+
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/microsoft/IIS.ServiceMonitor/releases/download/v2.0.1.10/ServiceMonitor.exe" -OutFile "C:\ServiceMonitor.exe"
16+
17+
EXPOSE 80
18+
19+
ENTRYPOINT ["C:\\LogMonitor\\LogMonitor.exe", "C:\\ServiceMonitor.exe", "w3svc"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"LogConfig": {
3+
"logFormat": "json",
4+
"sources": [
5+
{
6+
"type": "File",
7+
"directory": "c:\\inetpub\\logs",
8+
"filter": "*.log",
9+
"includeSubdirectories": true
10+
},
11+
{
12+
"type": "ETW",
13+
"eventFormatMultiLine": false,
14+
"providers": [
15+
{
16+
"providerName": "IIS: WWW Server",
17+
"providerGuid": "3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83",
18+
"level": "Information"
19+
},
20+
{
21+
"providerName": "Microsoft-Windows-IIS-Logging",
22+
"providerGuid": "7E8AD27F-B271-4EA2-A783-A47BDE29143B",
23+
"level": "Information"
24+
}
25+
]
26+
}
27+
]
28+
}
29+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Setup Guide
2+
3+
## Prerequisites
4+
5+
- The following tools:
6+
- [_Docker desktop_](https://docs.docker.com/desktop/install/windows-install/)
7+
- [_Azure CLI_](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli)
8+
- Azure subscription with a few credits
9+
10+
### Build the images
11+
12+
- Change into the example folder (one-line or step-by-step):
13+
14+
```powershell
15+
cd .\examples\aks\iis-logmonitor
16+
```
17+
18+
- Build the Docker image from the Dockerfile in this folder, tag it for Docker Hub, and push:
19+
20+
```powershell
21+
# build (run from examples/aks/iis-logmonitor)
22+
docker build -t <dockerhub-username>/iis-logmonitor:latest -f Dockerfile .
23+
24+
# login to Docker Hub (interactive)
25+
docker login
26+
27+
# push
28+
docker push <dockerhub-username>/iis-logmonitor:latest
29+
```
30+
31+
### Create AKS Cluster
32+
33+
> _Run all this from Powershell_
34+
35+
- `az login` (if you have multiple subscriptions, make sure you have the right subscription set as default.)
36+
- cd into `ps-scripts`
37+
- Update `vars.txt`
38+
- Run `./rg-create.ps1` to create the resource group.
39+
- Run `./aks-create.ps1` - the script creates an AKS cluster, adds a Windows node pool and connects to the cluster.
40+
41+
### Deploy the application
42+
43+
```powershell
44+
./deploy.ps1
45+
```
46+
47+
After a few minutes, check the status of the pods
48+
```powershell
49+
kubectl get pods
50+
NAME READY STATUS RESTARTS AGE
51+
iislogmonitor-95c488777-fkhgt 1/1 Running 0 2m5s
52+
```
53+
This indicates the pod started successfully — `READY 1/1` and `STATUS Running` show the container is healthy.
54+
55+
Check the service status and external IP, you should get something similar to:
56+
57+
```powershell
58+
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
59+
# kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 36m
60+
# iislogmonitor LoadBalancer 10.0.191.38 52.188.177.226 80:31349/TCP 2m19s
61+
```
62+
63+
Access the app using the `http://EXTERNAL-IP` shown in the output, for example:`http://52.188.177.226`
64+
65+
```powershell
66+
Start-Process "http://52.188.177.226"
67+
```
68+
To stream the container logs from that pod, run:
69+
70+
```powershell
71+
kubectl logs -f iislogmonitor-95c488777-fkhgt
72+
```
73+
74+
### Configure Azure Monitor (Container Insights)
75+
76+
You can enable AKS monitoring (Container Insights) from the Azure portal. Open the following onboarding view and follow the steps to enable monitoring for this cluster (select or create a Log Analytics workspace, then enable):
77+
78+
After onboarding completes you can view container logs, metrics and insights in Azure Monitor > Container insights for the cluster.
79+
80+
To query container logs (Log Analytics) for IIS entries you can run a KQL query in the Log Analytics `Logs` view. Example:
81+
82+
```kql
83+
// Find In ContainerLogV2
84+
ContainerLogV2
85+
| where LogMessage contains "W3SVC"
86+
```
87+
88+
This returns container log entries that include IIS/W3SVC messages collected by Container Insights.
89+
90+
The screenshots below show the Azure Monitor onboarding and Log Analytics views for this example.
91+
92+
![iis1.png](images/iis1.png)
93+
94+
![iis2.png](images/iis2.png)
95+
96+
![iis3.png](images/iis3.png)
97+
98+
![iis4.png](images/iis4.png)
99+
100+
![iis5.png](images/iis5.png)
101+
102+
### Clean-up
103+
104+
Clean up by deleting the resource group, in `ps-scripts`, run: `./clean-up.ps1`

0 commit comments

Comments
 (0)