.Net core client access Skywalking
Before the end of a build Skywalking service has been introduced, this article, we will access probe in the .net core clients, monitoring .net core applications.
A. Nuget packet introduced
Their new project or take a webAPI previous projects will do. In the package manager search inside nuget package: SkyAPM.Agent.AspNetCore, this time using the 0.8.0 version
II. Adding Environment Variables
Add the environment variable ASPNETCORE_HOSTINGSTARTUPASSEMBLIES = SkyAPM.Agent.AspNetCore, add the environment variable in the following ways
Direct add a system environment variables, so all of the projects are to take effect
Add in the project, you can
launchSettings.json
either start adding items inside the configuration, two effects are the same
III. Add a profile
There are also several ways to add configuration, found from the source code, the loading sequence is configured to load the default configuration ( you can enter AddSkyWalkingDefaultConfig view the source code, which contains all the default configuration skywalking.json item ), then load appsettings.json, skywalking.json the default configuration of all skywalking.json can be completely removed first, and then set up when needed, more concise point of fact, we need skywalking.json, you can just use appsettings.json.
builder.AddSkyWalkingDefaultConfig();
builder.AddJsonFile("appsettings.json", true).AddJsonFile($"appsettings.{environmentProvider.EnvironmentName}.json", true);
builder.AddJsonFile("skywalking.json", true).AddJsonFile($"skywalking.{environmentProvider.EnvironmentName}.json", true);
1. Automatically generated by script commands SkyWalking
First install SkyWalking DotNet CLI using the following command
dotnet tool install -g SkyWalking.DotNet.CLI
This step After installation is complete, you can also choose to .net core Agent to the current machine (optional, wrote later how to use)
dotnet skywalking install
This step of the installation requires attention to the following:
- Use administrator privileges to run cmd
- Run must be cut to the C drive path
- If the "Access to the path '06806e6c49431d12b85aaa5db07b8705d5b317' is denied" error, please delete: After the "C / Users / username /AppData/Local/Temp/skywalking.agent.aspnetcore", re-execution;
Installation may be slower, but we must wait until the final output SkyWalking .NET Core Agent was successfully installed
only on behalf of success
Then you can use the command to generate skywalking.json
configuration files
dotnet skywalking config [application_code] [collector_server]
{
"SkyWalking": {
"ServiceName": "your_service_name",
"Namespace": "",
"HeaderVersions": [
"sw6"
],
"Sampling": {
"SamplePer3Secs": -1,
"Percentage": -1.0
},
"Logging": {
"Level": "Information",
"FilePath": "logs/skyapm-{Date}.log"
},
"Transport": {
"Interval": 3000,
"ProtocolVersion": "v6",
"QueueSize": 30000,
"BatchSize": 3000,
"gRPC": {
"Servers": "localhost:11800",
"Timeout": 10000,
"ConnectTimeout": 10000,
"ReportTimeout": 600000
}
}
}
}
2. directly .net profile appsettings.json core of
In this way it is relatively simple, direct skywalking join in the project in the appsettings.json configuration node on the line
"SkyWalking": {
//服务名
"ServiceName": "Aggreg_2",
"Logging": {
"Level": "Information",
"FilePath": "logs\\skyapm-{Date}.log"
},
"Transport": {
"gRPC": {
//采集的地址
"Servers": "192.168.1.219:11800"
}
}
}
IV. Start Service
After starting the service, you can log file in the project folder inside to see the log format produced in accordance with
See what it means access to information success
Then you can request several times, to see the effect of the UI interface, you can see the service name from the figure, requests to have the
V. expansion
Currently installed .net core Agent by introducing nuget package, if the service is more and more, each service requires the introduction of the probe, due to the current development skywalking very quickly, if, when the upgrade, then need to be replaced nuget package for all services, very troublesome , so this time we can use previously mentioned probe installed locally to access the .net core application (currently not tried this approach, but with reference to the relevant blog), agreed to configure the environment variables and configuration files after, you can run the following command
set DOTNET_ADDITIONAL_DEPS=%PROGRAMFILES%\dotnet\x64\additionalDeps\skywalking.agent.aspnetcore
dotnet run
Of course, now skywalking developing very rapidly, many components will gradually support, but at the moment it is sql query interface and functionality is already completed enough.