### Sample Request: GET /processes Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/processes-list.md An example request to list processes, including the Host header and a Bearer token for authentication. ```http GET /processes HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### Sample Response for GET /process Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/process-get.md Sample response for a successful GET /process request, returning a ProcessInfo object in JSON format. ```http HTTP/1.1 200 OK Content-Type: application/json { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b", "name": "dotnet", "commandLine": "\"C:\\Program Files\\dotnet\\dotnet.exe\" ConsoleApp1.dll", "operatingSystem": "Windows", "processArchitecture": "x64", "managedEntryPointAssemblyName": "ConsoleApp1" } ``` -------------------------------- ### Install dotnet-monitor prerelease global tool Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/setup.md Installs the latest prerelease (LKG) version of the dotnet-monitor global tool from the private CI feed. ```cmd dotnet tool install -g dotnet-monitor --add-source https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet-tools/nuget/v3/index.json --prerelease ``` -------------------------------- ### Install dotnet monitor as a global tool Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/localmachine.md Use this command to install the latest version of the dotnet-monitor global tool. ```cmd dotnet tool install -g dotnet-monitor ``` -------------------------------- ### Sample Response for GET /env Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/process-env.md Sample response for a successful GET /env request, returning a JSON map of environment variables. The content type is application/json. This example demonstrates the shape of the response body as documented. ```http HTTP/1.1 200 OK Content-Type: application/json { "ALLUSERSPROFILE": "C:\\ProgramData", "APPDATA": "C:\\Users\\user\\AppData\\Roaming", "CommonProgramFiles": "C:\\Program Files\\Common Files", "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files", "CommonProgramW6432": "C:\\Program Files\\Common Files", "ComSpec": "C:\\WINDOWS\\system32\\cmd.exe", "DriverData": "C:\\Windows\\System32\\Drivers\\DriverData", "HOMEDRIVE": "C:", "HOMEPATH": "\\Users\\user", "LOCALAPPDATA": "C:\\Users\\user\\AppData\\Local", "NUMBER_OF_PROCESSORS": "8", "OS": "Windows_NT", "Path": "...", "PROCESSOR_ARCHITECTURE": "AMD64", "ProgramData": "C:\\ProgramData", "ProgramFiles": "C:\\Program Files", "ProgramFiles(x86)": "C:\\Program Files (x86)", "ProgramW6432": "C:\\Program Files", "PUBLIC": "C:\\Users\\Public", "SESSIONNAME": "Console", "SystemDrive": "C:", "SystemRoot": "C:\\WINDOWS", "TEMP": "C:\\Users\\user\\AppData\\Local\\Temp", "TMP": "C:\\Users\\user\\AppData\\Local\\Temp", "USERNAME": "user", "USERPROFILE": "C:\\Users\\user", "windir": "C:\\WINDOWS" } ``` -------------------------------- ### Start dotnet monitor with 'dotnet-monitor collect' Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/localmachine.md Run this command from a PowerShell or Command prompt to start collecting diagnostics. Assumes a default process is configured. ```cmd dotnet-monitor collect ``` -------------------------------- ### Example settings.json for MonitorApiKey authentication Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api-key-setup.md Shows a typical settings.json file for configuring the MonitorApiKey on a local dev box. The values shown are placeholders and not valid; run 'dotnet monitor generatekey --output json' to get a unique authentication key. ```json { "$schema": "https://aka.ms/dotnet-monitor-schema", "Authentication": { "MonitorApiKey": { "Subject": "ae5473b6-8dad-498d-b915-ffffffffffff", "PublicKey": "eyffffffffffffFsRGF0YSI6e30sIkNydiI6IlAtMzg0IiwiS2V5T3BzIjpbXSwiS3R5IjoiRUMiLCJYIjoiTnhIRnhVZ19QM1dhVUZWVzk0U3dUY3FzVk5zNlFLYjZxc3AzNzVTRmJfQ3QyZHdpN0RWRl8tUTVheERtYlJuWSIsIlg1YyI6W10sIlkiOiJmMXBDdmNoUkVpTWEtc1h6SlZQaS02YmViMHdrZmxfdUZBN0Vka2dwcjF5N251Wmk2cy1NcHl5RzhKdVFSNWZOIiwiS2V5U2l6ZSI6Mzg0LCJIYXNQcml2YXRlS2V5IjpmYWxzZSwiQ3J5cHRvUHJvdmlkZXJGYWN0b3J5Ijp7IkNyeXB0b1Byb3ZpZGVyQ2FjaGUiOnt9LCJDYWNoZVNpZ25hdHVyZVByb3ZpZGVycyI6dHJ1ZSwiU2lnbmF0dXJlUHJvdmlkZXJPYmplY3RQb29sQ2FjaGffffffffffff19" } } } ``` -------------------------------- ### ProcessInfo JSON Example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/definitions.md Example JSON response for the ProcessInfo object. Shows the pid, uid, name, commandLine, operatingSystem, and processArchitecture properties. The uid is a GUID that uniquely identifies a runtime instance within a process, useful in environments where process IDs may not be unique. ```json { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b", "name": "dotnet", "commandLine": "\"C:\\Program Files\\dotnet\\dotnet.exe\" ConsoleApp1.dll", "operatingSystem": "Windows", "processArchitecture": "x64" } ``` -------------------------------- ### Example output of generatekey command Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api-key-setup.md Example output from the generatekey command, showing the Authorization header and the JSON settings to merge into settings.json. The values are edited and will not work as valid configuration. ```yaml Tell us about your experience with dotnet monitor: https://aka.ms/dotnet-monitor-survey Generated ApiKey for dotnet-monitor; use the following header for authorization: Authorization: Bearer eyJhbGciOiJFUffffffffffffCI6IkpXVCJ9.eyJhdWQiOiJodffffffffffffGh1Yi5jb20vZG90bmV0L2RvdG5ldC1tb25pdG9yIiwiaXNzIjoiaHR0cHM6Ly9naXRodWIuY29tL2RvdG5ldC9kb3RuZXQtbW9uaXRvci9nZW5lcmF0ZWtleStNb25pdG9yQXBpS2V5Iiwic3ViIjoiYWU1NDczYjYtOGRhZC00OThkLWI5MTUtNTNiOWM2ODQwMDBlIn0.RZffffffffffff_yIyApvFKcxFpDJ65HJZek1_dt7jCTCMEEEffffffffffffR08OyhZZHs46PopwAsf_6fdTLKB1UGvLr95volwEwIFnHjdvMfTJ9ffffffffffffAU Settings in Json format: { "Authentication": { "MonitorApiKey": { "Subject": "ae5473b6-8dad-498d-b915-ffffffffffff", "PublicKey": "eyffffffffffffFsRGF0YSI6e30sIkNydiI6IlAtMzg0IiwiS2V5T3BzIjpbXSwiS3R5IjoiRUMiLCJYIjoiTnhIRnhVZ19QM1dhVUZWVzk0U3dUY3FzVk5zNlFLYjZxc3AzNzVTRmJfQ3QyZHdpN0RWRl8tUTVheERtYlJuWSIsIlg1YyI6W10sIlkiOiJmMXBDdmNoUkVpTWEtc1h6SlZQaS02YmViMHdrZmxfdUZBN0Vka2dwcjF5N251Wmk2cy1NcHl5RzhKdVFSNWZOIiwiS2V5U2l6ZSI6Mzg0LCJIYXNQcml2YXRlS2V5IjpmYWxzZSwiQ3J5cHRvUHJvdmlkZXJGYWN0b3J5Ijp7IkNyeXB0b1Byb3ZpZGVyQ2FjaGUiOnt9LCJDYWNoZVNpZ25hdHVyZVByb3ZpZGVycyI6dHJ1ZSwiU2lnbmF0dXJlUHJvdmlkZXJPYmplY3RQb29sQ2FjaGffffffffffff19" } } } ``` -------------------------------- ### CPUUsage Trigger Example JSON Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/collectionrules/triggershortcuts.md Example usage of the CPUUsage trigger shortcut in JSON format, which triggers when CPU usage is higher than 50% for a 1-minute window, using the default settings. ```json { "Trigger": { "Type": "CPUUsage" } } ``` -------------------------------- ### Sample Request: GET /logs with pid or uid Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/logs-get.md Two sample GET requests to the logs endpoint. The first uses the pid query parameter, the second uses the uid parameter. Both include the required Authorization header with a Bearer token. ```http GET /logs?pid=21632&level=Information&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` ```http GET /logs?uid=cd4da319-fa9e-4987-ac4e-e57b2aac248b&level=Information&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### Sample Request - GET /livemetrics Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/livemetrics-get.md Example HTTP GET request to retrieve metrics for a process with pid 21632 and duration 60 seconds, using Bearer authentication. ```http GET /livemetrics?pid=21632&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### ProcessIdentifier JSON example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/definitions.md Example JSON for the ProcessIdentifier object, containing pid and uid fields. The uid is a GUID that uniquely identifies a runtime instance within a process. ```json { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b" } ``` -------------------------------- ### Clone, build, and test on Windows Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/building.md Clone, build, and test the repository on Windows using the provided batch scripts. ```cmd cd $HOME git clone https://github.com/dotnet/dotnet-monitor cd dotnet-monitor .\Build.cmd .\Test.cmd ``` -------------------------------- ### GET /process Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/process-get.md This snippet documents the GET /process endpoint, which retrieves detailed information about a specified process using optional query parameters (pid, uid, name). It includes request examples, response schema, and error responses. ```APIDOC ## [GET] /process?pid={pid}&uid={uid}&name={name} ### Description Gets detailed information about a specified process. If none of `pid`, `uid`, or `name` are specified, information about the default process will be provided. ### Method GET ### Endpoint /process?pid={pid}&uid={uid}&name={name} ### Parameters #### Query Parameters - **pid** (int) - Optional - The ID of the process. - **uid** (guid) - Optional - A value that uniquely identifies a runtime instance within a process. - **name** (string) - Optional - The name of the process. ### Request Example ```http GET /process?pid=21632 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` or ```http GET /process?uid=cd4da319-fa9e-4987-ac4e-e57b2aac248b HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` ### Response #### Success Response (200) - **pid** (int) - The process ID. - **uid** (guid) - The unique identifier of the runtime instance. - **name** (string) - The name of the process. - **commandLine** (string) - The command line used to start the process. - **operatingSystem** (string) - The operating system of the process. - **processArchitecture** (string) - The architecture of the process. - **managedEntryPointAssemblyName** (string) - The managed entry point assembly name. #### Response Example ```json { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b", "name": "dotnet", "commandLine": "\"C:\\Program Files\\dotnet\\dotnet.exe\" ConsoleApp1.dll", "operatingSystem": "Windows", "processArchitecture": "x64", "managedEntryPointAssemblyName": "ConsoleApp1" } ``` ### Error Responses - **400 Bad Request** - An error occurred due to invalid input. The response body describes the specific problem(s). - **401 Unauthorized** - Authentication is required to complete the request. ``` -------------------------------- ### Collect Trace on Startup - JSON Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/collectionrules/collectionruleexamples.md JSON configuration for a collection rule named 'AssemblyLoadTraceOnStartup' that triggers on process startup, collects a trace for 15 seconds, and egresses to the 'artifacts' provider. The trace captures events from 'Microsoft-Windows-DotNETRuntime' at Informational level with keyword 0xC. Rundown is requested by default and BufferSizeInMB defaults to 256 MB. ```json { "AssemblyLoadTraceOnStartup": { "Trigger": { "Type": "Startup" }, "Actions": [ { "Type": "CollectTrace", "Settings": { "Providers": [{ "Name": "Microsoft-Windows-DotNETRuntime", "EventLevel": "Informational", "Keywords": "0xC" }], "Duration": "00:00:15", "Egress": "artifacts" } } ] } } ``` -------------------------------- ### GET /trace Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/trace-get.md Starts a trace operation for a specified process, collecting diagnostics data for a specified duration. The trace data is returned as a chunk-encoded response body. ```APIDOC ## GET /trace ### Description Starts a trace operation for a specified process, collecting diagnostics data for a specified duration. The trace data is returned as a chunk-encoded response body. ### Method GET ### Endpoint /trace ### Parameters #### Query Parameters - **pid** (integer) - Optional - The process ID of the target process. Use either `pid` or `uid`. - **uid** (string) - Optional - The unique ID of the target process. Use either `pid` or `uid`. - **profile** (string) - Required - The trace profile(s) to collect, comma-separated (e.g., `http,metrics`). - **durationSeconds** (integer) - Required - The duration of the trace in seconds. Use `-1` for an indefinite duration. ### Request Example ```http GET /trace?pid=21632&profile=http,metrics&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` or ```http GET /trace?uid=cd4da319-fa9e-4987-ac4e-e57b2aac248b&profile=http,metrics&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` ### Response #### Success Response (200) - **Content-Type** (string) - `application/octet-stream` - **Transfer-Encoding** (string) - `chunked` - **Location** (string) - The URI of the trace operation. #### Response Example ```http HTTP/1.1 200 OK Content-Type: application/octet-stream Transfer-Encoding: chunked Location: localhost:52323/operations/67f07e40-5cca-4709-9062-26302c484f18 ``` ``` -------------------------------- ### POST /trace with uid parameter Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/trace-custom.md Starts a trace operation using the unique ID (uid) and durationSeconds. The request body is identical to the pid example. The response is a chunk-encoded .nettrace file. ```http POST /trace?uid=cd4da319-fa9e-4987-ac4e-e57b2aac248b&durationSeconds=60 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= Content-Type: application/json { "Providers": [{ "Name": "Microsoft-DotNETCore-SampleProfiler", "EventLevel": "Informational" },{ "Name": "Microsoft-Windows-DotNETRuntime", "EventLevel": "Informational", "Keywords": "0x14C14FCCBD" }], "BufferSizeInMB": 1024 } ``` -------------------------------- ### GET /livemetrics Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/livemetrics-custom.md Starts live metric collection using System.Diagnostics.Metrics (8.0+). The request specifies the process ID, duration, and meter configuration. The response streams metric values, including histograms. ```APIDOC ## GET /livemetrics ### Description Starts live metric collection using System.Diagnostics.Meters. The request specifies the process ID, duration, and meter configuration. The response streams metric values as JSON sequences. ### Method GET ### Endpoint /livemetrics ### Parameters #### Query Parameters - **pid** (int) - Required - Process ID to collect metrics from. - **durationSeconds** (int) - Required - Duration of the metric collection in seconds. #### Request Body - **includeDefaultProviders** (bool) - Required - Whether to include default providers. - **meters** (array) - Required - List of meter configurations. - **meterName** (string) - Required - Name of the meter. - **instrumentNames** (array of string) - Required - List of instrument names to collect. ### Request Example ```json { "includeDefaultProviders": false, "meters": [ { "meterName": "CustomMeter", "instrumentNames": [ "myHistogram" ] } ] } ``` ### Response #### Success Response (200) Returns a stream of JSON objects separated by ASCII Record Separator (0x1E). Each object contains: - **timestamp** (string) - Timestamp of the metric. - **provider** (string) - Meter name. - **name** (string) - Instrument name. - **displayName** (string) - Display name. - **unit** (string) - Unit of the metric. - **counterType** (string) - Type of counter. - **tags** (string) - Tags associated with the metric, e.g., Percentile. - **value** (number) - Metric value. #### Response Example ```json { "timestamp": "2021-08-31T16:58:39.7514031+00:00", "provider": "CustomMeter", "name": "myHistogram", "displayName": "myHistogram", "unit": null, "counterType": "Metric", "tags": "Percentile=50", "value": 2292 } ``` ### Authentication Authorization: Bearer token required. ``` -------------------------------- ### LogsConfiguration example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/definitions.md Configuration for collecting logs for the Microsoft.AspNetCore.Hosting category at Information level or higher, with useAppFilters set to false. ```json { "filterSpecs": { "Microsoft.AspNetCore.Hosting": "Information" }, "useAppFilters": false } ``` -------------------------------- ### Show configuration providers with dotnet-monitor config show --show-sources Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/view-merged-configuration.md Run this command to view the loaded configuration providers. The --show-sources option adds provider information to the output. ```cmd dotnet-monitor config show --show-sources ``` -------------------------------- ### Collection Rule Architecture Flowchart Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/learningPath/collectionrules.md Flowchart showing the simplified interaction between dotnet monitor and dotnet diagnostics for running collection rules. It outlines the setup phase (load configuration, connect to processes, start pipelines) and the repeat phase (wait for trigger, check throttling, execute actions). ```mermaid %%{ init: { 'flowchart': { 'curve': 'basis' } } }%% graph LR classDef altColor fill:#CAF,stroke:purple; subgraph ide1 [Set-Up] A[Configuration] --> N{.NET Monitor} N --> |1| O[Load Configuration and Bind Options] N --> |2| P[Connect to Processes in Reverse Mode] N --> |3| Q[Start Pipelines For Processes That Match Filters] end subgraph ide2 [Repeat until Rule Limits Reached] N ---> |4| R[Wait To Satisfy Trigger - See Diagram B] N ---> |5| V[Check For Throttling] N ---> |6| W[Execute Action List] end class ide2 altColor ``` -------------------------------- ### Sample Request 2: GET /operations?name=dotnet-monitor-demo Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/operations-list.md HTTP request to list operations filtered by process name. ```http GET /operations?name=dotnet-monitor-demo HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### Show merged configuration with dotnet monitor config show Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/view-merged-configuration.md Run this command to output the merged configuration from all sources. The output is a JSON object with settings like urls, Kestrel, DiagnosticPort, Metrics, Storage, Authentication, and Egress. ```cmd dotnet monitor config show ``` -------------------------------- ### Sample Response: 200 OK with Process Identifiers Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/processes-list.md An example response showing a 200 OK status with a JSON array of process identifier objects, each containing a pid and a uid. ```http HTTP/1.1 200 OK Content-Type: application/json [ { "pid": 15000, "uid": "7b03fa5a-88ef-4630-899d-418bc0a3eb76" }, { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b" }, { "pid": 3380, "uid": "38f3eab1-c172-48b8-8dfd-b26986b37741" } ] ``` -------------------------------- ### darc get-subscriptions and update-subscription example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/release-process.md Shows how to view existing subscriptions and update a subscription using darc. The output shows the subscription ID and the command to update it. ```text darc get-subscriptions --target-repo https://github.com/dotnet/dotnet-monitor --target-branch release/8.x https://github.com/dotnet/installer (.NET 8.0.1xx SDK Preview 5) ==> 'https://github.com/dotnet/dotnet-monitor' ('release/8.x') - Id: 2f528213-5355-43ec-0bf5-08db410c84fe darc update-subscription --id 2f528213-5355-43ec-0bf5-08db410c84fe darc get-subscriptions --target-repo https://github.com/dotnet/dotnet-monitor --target-branch release/8.x https://github.com/dotnet/installer (.NET 8.0.1xx SDK Preview 6) ==> 'https://github.com/dotnet/dotnet-monitor' ('release/8.x') - Id: 2f528213-5355-43ec-0bf5-08db410c84fe darc update-dependencies --id 288422 ``` -------------------------------- ### Sample Request for Get Operation Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/operations-get.md Sample request to get an operation. Uses the default host address and includes a Bearer token for authentication. ```http GET /operations/67f07e40-5cca-4709-9062-26302c484f18 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### ValidationProblemDetails JSON example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/definitions.md Example JSON response for a validation problem, showing the structure of the ValidationProblemDetails object with a title, status, and errors map. ```json { "title": "One or more validation errors occurred.", "status": 400, "errors": { "Providers": [ "The Providers field is required." ] } } ``` -------------------------------- ### SetEnvironmentVariable Action JSON Example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/collection-rule-configuration.md JSON configuration for the SetEnvironmentVariable action, setting the Name and Value properties. This example sets an account ID for a profiler. ```json { "Name": "MyProfiler_AccountId", "Value": "8fb138d2c44e4aea8545cc2df541ed4c" } ``` -------------------------------- ### Clone, build, and test on Linux and macOS Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/building.md Clone, build, and test the repository on Linux and macOS using the provided shell scripts. ```bash cd $HOME git clone https://github.com/dotnet/dotnet-monitor cd dotnet-monitor ./build.sh ./test.sh ``` -------------------------------- ### Match MyApp.dll entry point (Shorthand) Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/default-process-configuration.md Configures dotnet-monitor to select the process whose managed entry point assembly is MyApp.dll using the shorthand format that omits the Key and Value terms. The JSON block shows the configuration file format, while the YAML blocks show the equivalent Kubernetes ConfigMap and environment variable formats. ```json { "DefaultProcess": { "Filters": [{ "ManagedEntryPointAssemblyName": "MyApp" }] }, } ``` ```yaml DefaultProcess__Filters__0__ManagedEntryPointAssemblyName: "MyApp" ``` ```yaml - name: DotnetMonitor_DefaultProcess__Filters__0__ManagedEntryPointAssemblyName value: "MyApp" ``` -------------------------------- ### CollectDump Action JSON Example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/collection-rule-configuration.md Example configuration for the CollectDump action in JSON format. It collects a full dump and egresses it to a provider named 'AzureBlobDumps'. ```json { "Type": "Full", "Egress": "AzureBlobDumps" } ``` -------------------------------- ### CPUUsage Trigger Example Kubernetes ConfigMap Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/collectionrules/triggershortcuts.md Example usage of the CPUUsage trigger shortcut in Kubernetes ConfigMap format, specifying the trigger type as 'CPUUsage'. ```yaml CollectionRules__RuleName__Trigger__Type: "CPUUsage" ``` -------------------------------- ### Dockerfile for dotnet-monitor container image Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/learningPath/aks.md Example Dockerfile for the dotnet-monitor container image. Sets environment variables to unset ASPNETCORE_URLS and ASPNETCORE_HTTP_PORTS, disables diagnostics, configures default process filter, enables server GC, and sets logging to JSON format with UTC timestamps. The entrypoint runs dotnet-monitor collect with specified URLs. ```dockerfile ARG REPO=mcr.microsoft.com/dotnet/aspnet FROM $REPO:8.0-alpine-amd64 WORKDIR /app ENV \ # Unset ASPNETCORE_URLS from aspnet base image ASPNETCORE_URLS= \ # Unset ASPNETCORE_HTTP_PORTS from aspnet base image (.NET 8+) ASPNETCORE_HTTP_PORTS= \ # Disable debugger and profiler diagnostics to avoid diagnosing self. DOTNET_EnableDiagnostics=0 \ # Default Filter DefaultProcess__Filters__0__Key=ProcessId \ DefaultProcess__Filters__0__Value=1 \ # Remove Unix Domain Socket before starting diagnostic port server DiagnosticPort__DeleteEndpointOnStartup=true \ # Server GC mode DOTNET_gcServer=1 \ # Logging: JSON format so that analytic platforms can get discrete entry information Logging__Console__FormatterName=simple \ # Logging: Use round-trip date/time format without timezone information (always logged in UTC) Logging__Console__FormatterOptions__TimestampFormat=yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff'Z' \ # Logging: Write timestamps using UTC offset (+0:00) Logging__Console__FormatterOptions__UseUtcTimestamp=true \ # Add dotnet-monitor path to front of PATH for easier, prioritized execution PATH="/app:${PATH}" COPY . . ENTRYPOINT [ "dotnet-monitor" ] CMD [ "collect", "--urls", "http://+:52323", "--metricUrls", "http://+:52325" ] ``` -------------------------------- ### OperationSummary JSON example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/definitions.md Example JSON response for the OperationSummary object, showing all fields including operationId, createdDateTime, status, egressProviderName, isStoppable, process, and tags. ```json { "operationId": "67f07e40-5cca-4709-9062-26302c484f18", "createdDateTime": "2021-07-21T06:21:15.315861Z", "status": "Succeeded", "egressProviderName": null, "isStoppable": false, "process": { "pid": 21632, "uid": "cd4da319-fa9e-4987-ac4e-e57b2aac248b", "name": "dotnet" }, "tags": [ "tag1", "tag2" ] } ``` -------------------------------- ### Sample Request with pid Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/api/gcdump.md Example request using the pid parameter to capture a GC dump for a specific process. ```http GET /gcdump?pid=21632 HTTP/1.1 Host: localhost:52323 Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff= ``` -------------------------------- ### LoadProfiler Action JSON Example Source: https://github.com/dotnet/dotnet-monitor/blob/main/documentation/configuration/collection-rule-configuration.md JSON configuration for the LoadProfiler action, specifying the profiler library path and CLSID. This example loads the gcallocateprofiler sample from dotnet/runtime. ```json { "Path": "Profilers\\Profiler.dll", "Clsid": "55b9554d-6115-45a2-be1e-c80f7fa35369" } ```