Skip to content

Commit 8bb97ec

Browse files
add code for prometheus monitoring guide
1 parent a906ff6 commit 8bb97ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+40230
-52
lines changed

prometheus-monitoring/application/main.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

prometheus-monitoring/docker-compose.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
version: "3"
22
services:
3-
my-application:
4-
build: ./application
5-
container_name: my-application
6-
image: my-application
3+
go-application:
4+
build:
5+
context: ./go-application
6+
container_name: go-application
7+
image: go-application
78
ports:
89
- "80:80"
10+
python-application:
11+
build:
12+
context: ./python-application
13+
container_name: python-application
14+
image: python-application
15+
ports:
16+
- "81:80"
17+
dotnet-application:
18+
build:
19+
context: ./dotnet-application
20+
container_name: dotnet-application
21+
image: dotnet-application
22+
ports:
23+
- "82:80"
24+
nodejs-application:
25+
build:
26+
context: ./nodejs-application
27+
container_name: nodejs-application
28+
image: nodejs-application
29+
ports:
30+
- "83:80"
931
prometheus:
1032
container_name: prometheus-svc
1133
image: prom/prometheus
@@ -21,4 +43,4 @@ services:
2143
environment:
2244
- GF_AUTH_BASIC_ENABLED=false
2345
- GF_AUTH_ANONYMOUS_ENABLED=true
24-
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
46+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch as debug
2+
3+
#install debugger for NET Core
4+
RUN apt-get update
5+
RUN apt-get install -y unzip
6+
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
7+
8+
RUN mkdir /work/
9+
WORKDIR /work/
10+
11+
COPY ./src/work.csproj /work/work.csproj
12+
RUN dotnet restore
13+
14+
COPY ./src/ /work/
15+
RUN mkdir /out/
16+
RUN dotnet publish --no-restore --output /out/ --configuration Release
17+
18+
ENTRYPOINT ["dotnet", "run"]
19+
20+
###########START NEW IMAGE###########################################
21+
22+
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim as prod
23+
24+
RUN mkdir /app/
25+
WORKDIR /app/
26+
COPY --from=debug /out/ /app/
27+
RUN chmod +x /app/
28+
CMD dotnet work.dll
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.AspNetCore.Mvc.RazorPages;
8+
9+
namespace work.Pages
10+
{
11+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
12+
public class ErrorModel : PageModel
13+
{
14+
public string RequestId { get; set; }
15+
16+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
17+
18+
public void OnGet()
19+
{
20+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
21+
}
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="text-center">
8+
<h1 class="display-4">Welcome</h1>
9+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
10+
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace work.Pages
9+
{
10+
public class IndexModel : PageModel
11+
{
12+
public void OnGet()
13+
{
14+
15+
}
16+
}
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace work.Pages
9+
{
10+
public class PrivacyModel : PageModel
11+
{
12+
public void OnGet()
13+
{
14+
}
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@using Microsoft.AspNetCore.Http.Features
2+
3+
@{
4+
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
5+
var showBanner = !consentFeature?.CanTrack ?? false;
6+
var cookieString = consentFeature?.CreateConsentCookie();
7+
}
8+
9+
@if (showBanner)
10+
{
11+
<div id="cookieConsent" class="alert alert-info alert-dismissible fade show" role="alert">
12+
Use this space to summarize your privacy and cookie use policy. <a asp-page="/Privacy">Learn More</a>.
13+
<button type="button" class="accept-policy close" data-dismiss="alert" aria-label="Close" data-cookie-string="@cookieString">
14+
<span aria-hidden="true">Accept</span>
15+
</button>
16+
</div>
17+
<script>
18+
(function () {
19+
var button = document.querySelector("#cookieConsent button[data-cookie-string]");
20+
button.addEventListener("click", function (event) {
21+
document.cookie = button.dataset.cookieString;
22+
}, false);
23+
})();
24+
</script>
25+
}

0 commit comments

Comments
 (0)