Comments (1)
Solved by using the following configs:
Program.cs
using App.Metrics;
using App.Metrics.AspNetCore;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(options =>
{
options.AllowSynchronousIO = true;
});
builder.Services
.AddControllers()
.AddMetrics();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddAppMetricsHealthPublishing();
builder.Services.AddAppMetricsSystemMetricsCollector();
builder.Host
.ConfigureMetricsWithDefaults(builder =>
{
builder.Report.ToInfluxDb(options =>
{
options.InfluxDb.Database = "demo";
options.InfluxDb.BaseUri = new Uri("http://127.0.0.1:8086");
options.InfluxDb.UserName = "user";
options.InfluxDb.Password = "123";
options.InfluxDb.CreateDataBaseIfNotExists = true;
options.FlushInterval = TimeSpan.FromSeconds(5);
});
})
.UseMetrics();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapControllers();
app.UseMetricsAllEndpoints();
app.UseMetricsAllMiddleware();
app.Run();
.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="App.Metrics.AspNetCore.All" Version="4.2.0" />
<PackageReference Include="App.Metrics.AspNetCore.Endpoints" Version="4.2.0" />
<PackageReference Include="App.Metrics.Graphite" Version="4.2.0" />
<PackageReference Include="App.Metrics.InfluxDB" Version="4.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
</Project>
docker-compose.yml
version: '3'
services:
influxdb:
image: influxdb:1.8
container_name: influxdb
restart: always
ports:
- 8086:8086
environment:
- INFLUXDB_DB=demo
- INFLUXDB_USER=user
- INFLUXDB_ADMIN_ENABLED=true
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=123
volumes:
- influxdb:/var/lib/influxdb
grafana:
container_name: "grafana"
image: "grafana/grafana:latest"
restart: always
ports:
- 3000:3000
volumes:
- grafana:/var/lib/grafana
volumes:
influxdb:
grafana:
OBS: On Grafana datasource config you use the container_name to set it up and on dotnet app use the localhost IP 127.0.0.1
from appmetrics.
Related Issues (20)
- how to publish metrics on service startup
- AppMetrics Maintenance Plan HOT 3
- Dynamic OutputMetrics via configuration
- InfluxDB not created on pushing metrics using HTTPS
- Reporter App.Metrics.Reporting.InfluxDb2.InfluxDbMetricsReporter FlushAsync failed
- Has AppMetrics been abandoned? HOT 4
- Potential new .NET runtime metrics APIs HOT 1
- Does the project still alive HOT 2
- Net6: runtime error 'Synchronous operations are disallowed'
- Using all data instead of Reservoir Sampling
- App Metrics Issue {"value": 0}
- ResetOnReporting is not passed to base ctor, BucketHistogram is not working properly
- net6 App.Metrics.Extensions.Reporting.ElasticSearch ?
- Formatters.GrafanaCloudHostedMetrics will send interval 0
- see memory usage
- AppMetrics generates a ton of string and string[]
- AppMetrics usage causes Native AoT build issues
- Metrics are not reported to InfluxDb v2 HOT 1
- Is this project still alive HOT 1
- AppMetrics compatibility with Opentelemetry automatic instrumentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appmetrics.