Skip to content

Commit

Permalink
Merged main into main-kr
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-docs-eng-opensource-bot authored Oct 17, 2024
2 parents 9220d6b + 140a098 commit d832cbd
Show file tree
Hide file tree
Showing 118 changed files with 4,543 additions and 3,359 deletions.
136 changes: 136 additions & 0 deletions src/content/docs/apm/agents/net-agent/net-agent-api/net-agent-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@ The following list contains the different calls you can make with the API, inclu
Associates a user ID to the current transaction (see below for more details).
</td>
</tr>

<tr>
<td class="children-nowrap">
`RecordDatastoreSegment`
</td>

<td>
Allows an unsupported datastore to be instrumented (see below for more details).
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -1104,6 +1114,132 @@ The following list contains the different calls you can make with the API, inclu
transaction.SetUserId("BobSmith123");
```
</Collapser>
<Collapser
id="RecordDatastoreSegment"
title="RecordDatastoreSegment"
>
### Syntax

```cs
SegmentWrapper? RecordDatastoreSegment(string vendor, string model, string operation, string? commandText = null, string? host = null, string? portPathOrID = null, string? databaseName = null)
```

Allows an unsupported datastore to be instrumented in the same way as the .NET agent automatically instruments its supported datastores.

This method requires .NET agent and .NET agent API [version 10.22.0](/docs/release-notes/agent-release-notes/net-release-notes/net-agent-10-22-0/) or higher.

### Parameters

<table>
<thead>
<tr>
<th>
Parameter
</th>

<th>
Description
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
`vendor`

_string_
</td>

<td>
Datastore vendor name, such as MySQL, MSSQL, or MongoDB.
</td>
</tr>
<tr>
<td>
`model`

_string_
</td>

<td>
Table name, or similar identifier in a non-relational datastore.
</td>
</tr>
<tr>
<td>
`operation`

_string_
</td>

<td>
Operation being performed, such as "SELECT" or "UPDATE" for SQL databases.
</td>
</tr>
<tr>
<td>
`commandText`

_string?_
</td>

<td>
Optional. Query, or similar descriptor in a non-relational datastore.
</td>
</tr>
<tr>
<td>
`host`

_string?_
</td>

<td>
Optional. Server hosting the datastore.
</td>
</tr>
<tr>
<td>
`portPathOrID`

_string?_
</td>

<td>
Optional. Port, path, or other identifier, paired with the host to aid in identifying the datastore.
</td>
</tr>
<tr>
<td>
`databaseName`

_string?_
</td>

<td>
Optional. Datastore name or similar identifier.
</td>
</tr>
</tbody>
</table>

### Returns

IDisposable segment wrapper that both creates and ends the segment automatically.

### Example

```cs
var transaction = NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction;
using (transaction.RecordDatastoreSegment(vendor, model, operation,
commandText, host, portPathOrID, databaseName))
{
DatastoreWorker();
}
```

</Collapser>
</CollapserGroup>
</Collapser>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If no data appears in the UI, try the following steps to diagnose the problem:
>
1. Use `dpkg` to verify that the agent is installed:

```
```sh
dpkg -l | grep newrelic-infra
```
2. If `dpkg` returns no output, see [Install with apt](/docs/infrastructure/new-relic-infrastructure/installation/install-infrastructure-linux#apt-based).
Expand All @@ -58,7 +58,7 @@ If no data appears in the UI, try the following steps to diagnose the problem:
>
1. Use `rpm` to verify that agent is installed:

```
```sh
rpm -qa | grep newrelic-infra
```
2. If `rpm` returns no output, see [Install with yum](/docs/infrastructure/new-relic-infrastructure/installation/install-infrastructure-linux#yum-based).
Expand All @@ -70,7 +70,7 @@ If no data appears in the UI, try the following steps to diagnose the problem:
>
1. Use the Windows command prompt or Powershell to verify that the [agent directory](/docs/agents/manage-apm-agents/troubleshooting/find-agent-root-directory#infra-agent) exists:

```
```sh
dir "C:\Program Files\New Relic\newrelic-infra"
```
2. If you receive a `File not found` error, see [Install for Windows Server](/docs/infrastructure/new-relic-infrastructure/installation/install-infrastructure-windows-server).
Expand All @@ -87,12 +87,12 @@ If no data appears in the UI, try the following steps to diagnose the problem:

1. Check that the agent is running:

```
```sh
sudo systemctl status newrelic-infra
```
2. If the agent isn't running, start the agent manually:
```
```sh
sudo systemctl start newrelic-infra
```
</Collapser>
Expand All @@ -105,12 +105,12 @@ If no data appears in the UI, try the following steps to diagnose the problem:
1. Check that the agent is running:
```
```sh
sudo /etc/init.d/newrelic-infra status
```
2. If the agent isn't running, start the agent manually:

```
```sh
sudo /etc/init.d/newrelic-infra start
```
</Collapser>
Expand All @@ -123,12 +123,12 @@ If no data appears in the UI, try the following steps to diagnose the problem:

1. Check that the agent is running:

```
```sh
sudo initctl status newrelic-infra
```
2. If the agent isn't running, start the agent manually:
```
```sh
sudo initctl start newrelic-infra
```
</Collapser>
Expand All @@ -141,13 +141,13 @@ If no data appears in the UI, try the following steps to diagnose the problem:
1. Check that the agent is running:
```
```sh
sc query "newrelic-infra" | find "RUNNING"
```
2. If the agent isn't running, start the agent manually with the Windows command prompt:

```
```sh
net start newrelic-infra
```

Expand All @@ -166,7 +166,7 @@ If no data appears in the UI, try the following steps to diagnose the problem:
6. Verify that no firewalls or proxies are blocking outbound connections from the agent process to the [Infrastructure domains and ports](/docs/apm/new-relic-apm/getting-started/networks#infrastructure).
7. Confirm the host is reporting correctly even though it is not appearing in the infrastructure monitoring UI by creating a basic query in Query builder, like:

```
```sql
SELECT * FROM SystemSample SINCE 60 minutes ago LIMIT 100
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Generating `debug` log files requires editing your configuration file. For a sam
<td>
Edit your `newrelic-infra.yml` file with logging settings:

```
```yml
log:
level: debug
file: /path/to/logfile.log
Expand Down Expand Up @@ -138,15 +138,15 @@ These are some additional notes and requirements for specific systems, used to s

* Recommended: Set the environment variable `NRIA_LOG_LEVEL` to `debug`. Running this on the command line would look like:

```
```sh
-e NRIA_LOG_LEVEL=debug
```

OR
* Edit the config file to set `level: debug` in the `log` section. (Editing the config file in a container is not recommended, because it requires rebuilding the image twice: once to add verbose logging and once to remove it.)
2. Use `journalctl` to collect the logs:

```
```sh
journalctl -u newrelic-infra > newrelic-infra.log
```
3. Set the logging level back to `info` or `warn` after collecting logs for a few minutes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ New Relic's infrastructure agent gathers its own data as well as integrations's

The following example shows a typical configuration for the agent log in Linux systems (change file path when running Windows or other platforms):

```
```yml
log:
level: info
file: '/var/log/newrelic-infra/newrelic-infra.log'
Expand Down Expand Up @@ -60,7 +60,7 @@ By default, Infrastructure logs are formatted as text:

Alternatively, logs can be formatted as a JSON file:

```
```json
{"context":{},"level":"info","msg":"upstart_interval_sec: 0","timestamp":"2019-07-11T18:24:03+02:00"}
{"context":{},"level":"info","msg":"plugin_dir: ","timestamp":"2019-07-11T18:24:03+02:00"}
```
Expand All @@ -81,18 +81,18 @@ For more information on how to enable smart verbose mode and the debug message l

## Integration log management

Integrations write JSON payloads into STDOUT and plain-text (JSON structured in the future) logs into STDERR.
Integrations write JSON payloads into `STDOUT` and plain-text (JSON structured in the future) logs into `STDERR`.

The infrastructure agent handles integration STDERR lines and forward this output into the agent log.
The infrastructure agent handles integration `STDERR` lines and forward this output into the agent log.

Agent handles each STDERR line as follows:
Agent handles each `STDERR` line as follows:

* <DNT>**when agent runs in verbose mode**</DNT>: it just forwards the full STDERR line as a DEBUG agent log entry placing integration line contexts within the \`msg\` field.
* <DNT>**otherwise**</DNT>: it parses the line against the expected format (see below) and only logs as agent ERROR level, entries produced by integrations with \`fatal\` or \`error\` severity levels. In this case fields are extracted and forwarded in structured manner (therefore if JSON output is enabled for the agent fields become queryable.
* <DNT>**When agent runs in verbose mode**</DNT>: it just forwards the full `STDERR` line as a DEBUG agent log entry placing integration line contexts within the `msg` field.
* <DNT>**Otherwise**</DNT>: it parses the line against the expected format (see below) and only logs as agent ERROR level, entries produced by integrations with `fatal` or `error` severity levels. In this case fields are extracted and forwarded in structured manner (therefore if JSON output is enabled for the agent fields become queryable.

By default, the infrastructure agent filters out any errors from integrations that don't prevent the integration from running. You'll only see all errors from an integration if the log level is set to DEBUG, or if the integration is specifically listed in the log configuration. For example, in this configuration, all errors coming from `nri-mssql` will be shown, even if the log level is INFO:

```YAML
```yml
log:
include_filters:
integration_name:
Expand All @@ -109,7 +109,7 @@ A line is expected to be a list of key-value pairs separated by an equal charact

Internally agent used this regex to extract the fields:

```
```regex
([^\s]*?)=(".*?[^\\]"|&{.*?}|[^\s]*)
```

Expand Down
Loading

0 comments on commit d832cbd

Please sign in to comment.