Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
33fbea7
see_sharp_game_api -
shreyasgune Feb 7, 2025
b0b4a57
see_sharp_game_api - web-api-draft
shreyasgune Feb 7, 2025
1a7bbb0
see_sharp_game_api - helm stuff
shreyasgune Feb 7, 2025
dc25724
see_sharp_game_api - terragrunt stuff
shreyasgune Feb 7, 2025
b4dde17
see_sharp_game_api -
shreyasgune Feb 8, 2025
06eaa0b
see_sharp_game_api -
shreyasgune Feb 8, 2025
36d0d07
see_sharp_game_api -
shreyasgune Feb 8, 2025
595758d
see_sharp_game_api -
shreyasgune Feb 8, 2025
6b522f9
see_sharp_game_api -
shreyasgune Feb 8, 2025
aac0b99
see_sharp_game_api -
shreyasgune Feb 8, 2025
e91c17e
see_sharp_game_api -
shreyasgune Feb 8, 2025
33a60e0
see_sharp_game_api - disable alertmanager
shreyasgune Feb 8, 2025
35b7bb6
see_sharp_game_api - fix plugin
shreyasgune Feb 8, 2025
955ac92
see_sharp_game_api - additional-fixes
shreyasgune Feb 8, 2025
096d9af
see_sharp_game_api - fix loki path
shreyasgune Feb 8, 2025
972f5f8
see_sharp_game_api - dashboards
shreyasgune Feb 8, 2025
09e73e9
see_sharp_game_api -
shreyasgune Feb 8, 2025
5c293b4
see_sharp_game_api - autoscaling
shreyasgune Feb 8, 2025
185e1ee
see_sharp_game_api -
shreyasgune Feb 8, 2025
f04f138
see_sharp_game_api -
shreyasgune Feb 8, 2025
6f616ac
see_sharp_game_api - name fix
shreyasgune Feb 8, 2025
687bd7f
see_sharp_game_api - name fix2
shreyasgune Feb 8, 2025
1bbbce4
see_sharp_game_api - namefix3
shreyasgune Feb 8, 2025
907dd81
see_sharp_game_api - another synk
shreyasgune Feb 8, 2025
6721fa3
see_sharp_game_api - minor-fix
shreyasgune Feb 8, 2025
49819fb
see_sharp_game_api -
shreyasgune Feb 8, 2025
56cb2ad
see_sharp_game_api - revert
shreyasgune Feb 8, 2025
423816b
see_sharp_game_api - resource-fix
shreyasgune Feb 8, 2025
9a62de8
see_sharp_game_api - resource-fix2
shreyasgune Feb 8, 2025
2025860
see_sharp_game_api - resource-fix5
shreyasgune Feb 8, 2025
a2c6568
see_sharp_game_api - resource-fix6
shreyasgune Feb 8, 2025
c4aed5e
see_sharp_game_api - resource-fix7
shreyasgune Feb 8, 2025
c9d1b01
see_sharp_game_api - resourcefix8
shreyasgune Feb 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.terragrunt
.terragrunt-cache
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ kubectl delete crd podmonitors.monitoring.coreos.com
kubectl delete crd alertmanagers.monitoring.coreos.com
kubectl delete crd thanosrulers.monitoring.coreos.com


helm delete --purge prometheus
```

Expand Down
25 changes: 21 additions & 4 deletions monitoring-stack/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ helm pull prometheus-community/kube-prometheus-stack --untar --untardir .

kubectl create namespace monitoring

helm install --dry-run --debug --namespace monitoring kube-prometheus-stack -f kube-prometheus-stack/values/custom-values.yaml ./kube-prometheus-stack # dry run
helm install --dry-run --debug --create-namespace --namespace monitoring kube-prometheus-stack -f kube-prometheus-stack/values/custom-values.yaml ./kube-prometheus-stack # dry run

helm upgrade --cleanup-on-fail --install --namespace monitoring kube-prometheus-stack -f kube-prometheus-stack/values/custom-values.yaml ./kube-prometheus-stack
helm upgrade --cleanup-on-fail --install --create-namespace --namespace monitoring kube-prometheus-stack -f kube-prometheus-stack/values/custom-values.yaml ./kube-prometheus-stack

helm diff upgrade --namespace monitoring kube-prometheus-stack -f kube-prometheus-stack/values/custom-values.yaml ./kube-prometheus-stack -C3

Expand All @@ -93,7 +93,7 @@ helm repo add grafana https://grafana.github.io/helm-charts

helm pull grafana/loki-stack --untar --untardir .

helm upgrade --cleanup-on-fail --install --namespace logging -f loki-stack/values/custom-values.yaml loki-stack ./loki-stack
helm upgrade --cleanup-on-fail --install --create-namespace --namespace logging -f loki-stack/values/custom-values.yaml loki-stack ./loki-stack

helm diff upgrade --namespace logging -f loki-stack/values/custom-values.yaml loki-stack ./loki-stack -C3

Expand Down Expand Up @@ -156,4 +156,21 @@ Tempo Configuration is explained here: https://github.com/shreyasgune/grafana-te
![](https://i.imgur.com/b1M763T.png)
![](https://i.imgur.com/ErQJyft.png)
![](https://i.imgur.com/jtefGfM.png)
![](https://i.imgur.com/jqNcdLD.png)
![](https://i.imgur.com/jqNcdLD.png)

# CI/CD
## ArgoCD
```

helm repo add argo https://argoproj.github.io/argo-helm

helm pull argo/argo-cd --untar --untardir .

helm upgrade --cleanup-on-fail --install --create-namespace --namespace argocd -f argo-cd/values/custom-values.yaml argo-cd ./argo-cd

helm diff upgrade --namespace argocd -f argo-cd/values/custom-values.yaml argo-cd ./argo-cd -C3

username:admin
passowrd:kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.username}" | base64 -d

```
17 changes: 17 additions & 0 deletions monitoring-stack/game-web-api-dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official .NET runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
WORKDIR /src/GameBackend
RUN dotnet publish -c Release -o /app/publish

# Final stage
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "GameBackend.dll"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.12" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@GameBackend_HostAddress = http://localhost:5053

GET {{GameBackend_HostAddress}}/weatherforecast/
Accept: application/json

###
105 changes: 105 additions & 0 deletions monitoring-stack/game-web-api-dotnet/GameBackend/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Linq;
using Prometheus;
using Microsoft.Extensions.Logging;
using Serilog;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Add logging
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console() // Standard output (visible in `kubectl logs`)
.CreateLogger();

// for LOKI, use .WriteTo.GrafanaLoki("http://loki-service:3100")

builder.Host.UseSerilog();



var app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();

// Create an ILogger instance
var logger = app.Services.GetRequiredService<ILogger<Program>>();

// Middleware for logging all incoming requests
app.Use(async (context, next) =>
{
logger.LogInformation("Received request: {Method} {Path} from {IP}",
context.Request.Method, context.Request.Path, context.Connection.RemoteIpAddress);

await next();
});


// In-memory database
var players = new List<Player>();

// Add a new player
app.MapPost("/players", (Player player) => {
players.Add(player);
return Results.Created($"/players/{player.Id}", player);
});


// Sample metric for player request total
// Creating a counter metric
var playerRequests = Metrics.CreateCounter("player_requests_total", "Total number of requests to the players endpoint");


//Fake Error Endpoint to simulate an error
app.MapGet("/error", () =>
{
logger.LogError("An error occurred in the /error endpoint."); // Simulate error logging
return Results.Problem("Simulated error");
});

// Get all players
app.MapGet("/players", () =>
{
playerRequests.Inc(); // Increment metric count
return Results.Ok(players);
});

// Get a specific player by ID
app.MapGet("/players/{id}", (int id) => {
var player = players.FirstOrDefault(p => p.Id == id);
return player is not null ? Results.Ok(player) : Results.NotFound();
});

// Update player score
app.MapPut("/players/{id}/score", (int id, int score) => {
var player = players.FirstOrDefault(p => p.Id == id);
if (player is not null) {
player.Score = score;
return Results.Ok(player);
}
return Results.NotFound();
});

// Expose metrics so that prometheus can scrape them
app.UseMetricServer();
app.UseHttpMetrics();

// Run the app
app.Run();

class Player
{
public int Id { get; set; }
public string Name { get; set; }

public int Score { get; set; }

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:22203",
"sslPort": 44309
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5053",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7049;http://localhost:5053",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("GameBackend")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423816b28450ae1c0863fd3827df1e06b41ac646")]
[assembly: System.Reflection.AssemblyProductAttribute("GameBackend")]
[assembly: System.Reflection.AssemblyTitleAttribute("GameBackend")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f7aac36e1eb36556e5b9666340c9639d6c9d73d3423992f3a69fb0ccecba0806
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = GameBackend
build_property.RootNamespace = GameBackend
build_property.ProjectDir = /home/sgune/devs/promfana/monitoring-stack/game-web-api-dotnet/GameBackend/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.RazorLangVersion = 8.0
build_property.SupportLocalizedComponentNames =
build_property.GenerateRazorMetadataSourceChecksumAttributes =
build_property.MSBuildProjectDirectory = /home/sgune/devs/promfana/monitoring-stack/game-web-api-dotnet/GameBackend
build_property._RazorSourceGeneratorDebug =
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Binary file not shown.
Loading