Skip to content

codeby-nurgul/grafana-dotnet-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grafana + Promtail + .NET Logging Demo

This is a demo project that shows how to send logs from a custom .NET Core application to Grafana using Promtail and Loki. All components are containerized using Docker Compose.


πŸ“¦ Project Structure

grafana-dotnet-logging/
β”œβ”€β”€ dotnet-app/
β”‚   β”œβ”€β”€ Program.cs              # Writes logs to app.log
β”‚   β”œβ”€β”€ LoggingDemo.csproj      # .NET 8 project
β”‚   β”œβ”€β”€ Dockerfile              # Containerizes the app
β”‚   └── logs/                   # Output log file directory (bind-mounted)
β”œβ”€β”€ promtail-config.yaml        # Promtail config for scraping app.log
β”œβ”€β”€ docker-compose.yml          # Defines Loki, Grafana, Promtail services
└── README.md

πŸš€ How to Run

# Build the .NET logging app
cd dotnet-app
docker build -t dotnet-log .

# Run the logging app (this writes logs into logs/app.log)
docker run --rm -v $(pwd)/logs:/app/logs dotnet-log

# Start Grafana, Loki and Promtail
cd ..
docker-compose up --build

πŸ”Ž View Logs in Grafana

  1. Access Grafana: http://localhost:3000
    • Username: admin, Password: admin
  2. Add Loki as a data source if not added automatically:
    • Data Sources β†’ Add β†’ Loki β†’ URL: http://loki:3100
  3. Go to Explore
  4. Use query:
    {job="dotnet-app"}
    

You should see the logs generated by the .NET app.


πŸ“š Related Tools

Tool Purpose
Grafana Visualization dashboards
Loki Log storage (time-series)
Promtail Log shipper to Loki
.NET Custom log-producing app

About

Demo project that sends .NET logs to Grafana using Loki and Promtail, fully containerized with Docker Compose.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors