> For the complete documentation index, see [llms.txt](https://docs.scepman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scepman.com/es/configuracion-de-azure/log-configuration.md).

# Administración de registros

### Habilitar el registro en Azure Monitor

Desde la versión 3.0, SCEPman y Certificate Master usan la API de ingesta de registros de Microsoft para enviar registros a Azure Monitor. Los registros se almacenan en un Log Analytics Workspace, y una Regla de recopilación de datos conecta los App Services con el área de trabajo. Este enfoque moderno usa permisos basados en RBAC para que SCEPman acceda al LAW.

La creación del Log Analytics Workspace, así como la configuración de la Regla de recopilación de datos, se realiza automáticamente ejecutando `Complete-SCEPmanInstallation` del módulo PowerShell de SCEPman.

```
Install-Module SCEPman -Scope CurrentUser -Force
Complete-SCEPmanInstallation 6>&1
```

{% hint style="info" %}
El **retención predeterminada** el período para los datos almacenados en una Log Analytics Table es **30 días**. En caso de que se requiera un período de retención diferente, ajuste la configuración de la tabla "SCEPman\_CL" en consecuencia.
{% endhint %}

#### Rehabilitación de la API de Data Collector

Si, por cualquier motivo, quieres volver a usar la API anterior, puedes hacerlo eliminando las variables de la app service relacionadas con Log Ingestion y volviendo a agregar las que utiliza la API de Data Collector.

Variables que se van a **eliminar**:

* [AppConfig:LoggingConfig:DataCollectionEndpointUri](/es/configuracion-de-scepman/application-settings/dependencies-azure-services/logging.md#appconfig-loggingconfig-datacollectionendpointuri)
* [AppConfig:LoggingConfig:RuleId](/es/configuracion-de-scepman/application-settings/dependencies-azure-services/logging.md#appconfig-loggingconfig-ruleid)

Variables que se van a agregar:

* [AppConfig:LoggingConfig:WorkspaceId](/es/configuracion-de-scepman/application-settings/dependencies-azure-services/logging.md#appconfig-loggingconfig-workspaceid)
* [AppConfig:LoggingConfig:SharedKey](/es/configuracion-de-scepman/application-settings/dependencies-azure-services/logging.md#appconfig-loggingconfig-sharedkey)

SCEPman recogerá automáticamente la configuración después de reiniciarse y volverá a utilizar la API de Data Collector.

## Ejemplos de consultas KQL

### Ver problemas con tu instancia de SCEPman

```kusto
SCEPman_CL
| where Level == "Warn" or Level == "Error" or Level == "Fatal"
```

### Número de certificados emitidos por punto final en el intervalo de tiempo seleccionado

{% hint style="success" %}
Esta consulta tiene garantía de funcionar con SCEPman 3.0 y versiones posteriores cuando se usa la API de ingesta de registros para el registro. Los cambios en SCEPman que hagan que esta consulta no pueda usarse se considerarán cambios importantes.
{% endhint %}

{% tabs %}
{% tab title="API de ingesta de registros ( Predeterminada )" %}

```kql
SCEPman_CL
| where Level == "Info" and Message startswith_cs "Issued a certificate with serial number"
| project Message, RequestBase = trim_end('/', replace_string(replace_string(replace_regex(RequestUrl, "(/pkiclient\\.exe)?(\\?operation=PKIOperation(&message=.+)?)?", ""),"certsrv/mscep/mscep.dll","intune"),"step/enrollment","activedirectory"))
| summarize IssuanceCount = count() by Endpoint = extract("/([a-zA-Z]+)$", 1, RequestBase)
```

{% endtab %}

{% tab title="API de Data Collector ( Antigua )" %}

```kusto
SCEPman_CL
| where Level == "Info" and Message startswith_cs "Issued a certificate with serial number"
| project Message, RequestBase = trim_end('/', replace_string(replace_string(replace_regex(RequestUrl_s, "(/pkiclient\\.exe)?(\\?operation=PKIOperation(&message=.+)?)?", ""),"certsrv/mscep/mscep.dll","intune"),"step/enrollment","activedirectory"))
| summarize IssuanceCount = count() by Endpoint = extract("/([a-zA-Z]+)$", 1, RequestBase)
```

{% endtab %}
{% endtabs %}

A partir de SCEPman 2.8, siempre hay exactamente una entrada de registro de nivel Info cuyo mensaje de registro comienza con "Issued a certificate with serial number " por cada certificado emitido, seguida de su número de serie. Sin embargo, debido al irresoluble [Problema de los dos ejércitos](https://en.wikipedia.org/wiki/Two_Generals'_Problem), puede ocurrir que el certificado creado nunca llegue al solicitante o que algún otro tipo de error impida la inscripción real. Del mismo modo, en caso de errores graves, puede ocurrir que exista una entrada de registro sin una entrada correspondiente en la base de datos o viceversa.

### Certificados distintos con comprobación OCSP

{% tabs %}
{% tab title="API de ingesta de registros ( Predeterminada )" %}

```kusto
let map_certtype = datatable(serial_start:string, readable:string)
[
  "40", "Dispositivo de Intune",
  "41", "Dispositivo de Intune",
  "42", "Dispositivo de Intune no conforme",
  "50", "Estático",
  "51", "Estático",
  "60", "Usuario de Intune",
  "61", "Usuario de Intune",
  "64", "Usuario de Jamf",
  "65", "Usuario de Jamf",
  "6C", "Usuario de Jamf en dispositivo",
  "6D", "Usuario de Jamf en dispositivo",
  "70", "Domain Controller",
  "7C", "Usuario de Jamf en equipo",
  "7D", "Usuario de Jamf en equipo",
  "54", "Equipo de Jamf",
  "55", "Equipo de Jamf",
  "44", "Dispositivo de Jamf",
  "45", "Dispositivo de Jamf"
];
SCEPman_CL
| where LogCategory == "Scepman.Server.Controllers.OcspController" and Level == "Info"
| where Message startswith_cs "OCSP Response"
| project serial = extract("Serial Number ([A-F0-9]+)", 1, Message)
| distinct serial
| extend serial_start = substring(serial,0,2)
| join kind=leftouter map_certtype on serial_start
| summarize count() by (readable)
```

{% endtab %}

{% tab title="API de Data Collector ( Antigua )" %}

```kql
let map_certtype = datatable(serial_start:string, readable:string)
[
  "40", "Dispositivo de Intune",
  "41", "Dispositivo de Intune",
  "42", "Dispositivo de Intune no conforme",
  "50", "Estático",
  "51", "Estático",
  "60", "Usuario de Intune",
  "61", "Usuario de Intune",
  "64", "Usuario de Jamf",
  "65", "Usuario de Jamf",
  "6C", "Usuario de Jamf en dispositivo",
  "6D", "Usuario de Jamf en dispositivo",
  "70", "Domain Controller",
  "7C", "Usuario de Jamf en equipo",
  "7D", "Usuario de Jamf en equipo",
  "54", "Equipo de Jamf",
  "55", "Equipo de Jamf",
  "44", "Dispositivo de Jamf",
  "45", "Dispositivo de Jamf"
];
SCEPman_CL
| where LogCategory_s == "Scepman.Server.Controllers.OcspController" and Level == "Info"
| where Message startswith_cs "OCSP Response"
| project serial = extract("Serial Number ([A-F0-9]+)", 1, Message)
| distinct serial
| extend serial_start = substring(serial,0,2)
| join kind=leftouter map_certtype on serial_start
| summarize count() by (readable)
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.scepman.com/es/configuracion-de-azure/log-configuration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
