-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example of using grafana loki for nbomber serilog logger (#691)
- Loading branch information
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
examples/Demo/Features/SerilogGrafanaLokiLogger/SerilogGrafanaLokiExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using NBomber.CSharp; | ||
using Serilog; | ||
using Serilog.Sinks.Grafana.Loki; | ||
|
||
namespace Demo.Features.SerilogGrafanaLokiLogger; | ||
|
||
public class SerilogGrafanaLokiExample | ||
{ | ||
public void Run() | ||
{ | ||
var scenario = Scenario.Create("hello_world_scenario", async context => | ||
{ | ||
await Task.Delay(1000); | ||
|
||
context.Logger.Information("my log message: {0}", context.InvocationNumber); | ||
|
||
return Response.Ok(); | ||
}) | ||
.WithoutWarmUp() | ||
.WithLoadSimulations( | ||
Simulation.KeepConstant(copies: 1, during: TimeSpan.FromSeconds(30)) | ||
); | ||
|
||
NBomberRunner | ||
.RegisterScenarios(scenario) | ||
.WithLoggerConfig(() => | ||
new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.GrafanaLoki("http://localhost:3100", | ||
new [] {new LokiLabel {Key = "application", Value = "NBomber"}}) | ||
) | ||
.Run(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/Demo/Features/SerilogGrafanaLokiLogger/docker-compose.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: "3" | ||
|
||
services: | ||
loki: | ||
image: grafana/loki:master | ||
ports: | ||
- 3100:3100 | ||
command: -config.file=/etc/loki/local-config.yaml | ||
|
||
grafana: | ||
image: grafana/grafana:master | ||
ports: | ||
- "3000:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters