> 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/de/azure-konfiguration/log-configuration.md).

# Protokollverwaltung

### Protokollierung in Azure Monitor aktivieren

Seit Version 3.0 verwendet SCEPman ebenso wie der Certificate Master die Log Ingestion API von Microsoft, um Protokolle in Azure Monitor zu schreiben. Dabei wird das Konzept eines Log Analytics Workspace verwendet, um die Daten zu speichern und Analysen zu ermöglichen, sowie eine Data Collection Rule, die zwischen dem App Service und dem Protokollspeicher vermittelt. Dies ermöglicht einen moderneren Ansatz einschließlich RBAC-basierter Berechtigungen für SCEPman, um auf den LAW zuzugreifen.

Die Erstellung des Log Analytics Workspace sowie die Konfiguration der Data Collection Rule erfolgt automatisch durch Ausführen `Complete-SCEPmanInstallation` des SCEPman-PowerShell-Moduls.

{% hint style="info" %}
Das **Standardaufbewahrung** Aufbewahrungszeitraum für in einer Log Analytics-Tabelle gespeicherte Daten ist **30 Tage**. Falls ein anderer Aufbewahrungszeitraum erforderlich ist, passen Sie die Konfiguration der Tabelle "SCEPman\_CL" entsprechend an.
{% endhint %}

#### Data Collector API erneut aktivieren

Wenn Sie aus irgendeinem Grund die vorherige API wieder verwenden möchten, können Sie dies tun, indem Sie die mit Log Ingestion verknüpften App-Service-Variablen entfernen und erneut die Variablen hinzufügen, die von der Data Collector API verwendet werden.

Zu entfernende Variablen **entfernt**:

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

Hinzuzufügende Variablen:

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

SCEPman übernimmt die Einstellungen nach einem Neustart automatisch und verwendet wieder die Data Collector API.

## KQL-Abfragebeispiele

### Probleme mit Ihrer SCEPman-Instanz anzeigen

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

### Anzahl ausgestellter Zertifikate pro Endpunkt im ausgewählten Zeitraum

{% hint style="success" %}
Diese Abfrage funktioniert garantiert mit SCEPman 3.0 und neuer, wenn die Log Ingestion API für die Protokollierung verwendet wird. Änderungen an SCEPman, die diese Abfrage unbrauchbar machen, gelten als Breaking Changes.
{% endhint %}

{% tabs %}
{% tab title="Log Ingestion API ( Standard )" %}

```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="Data Collector API ( Alt )" %}

```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 %}

Beginnend mit SCEPman 2.8 gibt es immer genau einen Protokolleintrag auf Info-Ebene, dessen Protokollmeldung mit "Issued a certificate with serial number " beginnt, pro ausgestelltem Zertifikat, gefolgt von dessen Seriennummer. Aufgrund des unlösbaren [Zwei-Armeen-Problem](https://en.wikipedia.org/wiki/Two_Generals'_Problem), kann es vorkommen, dass das erstellte Zertifikat den Anforderer nie erreicht oder ein anderer Fehler die eigentliche Registrierung verhindert. Ebenso kann es bei schwerwiegenden Fehlern vorkommen, dass ein Protokolleintrag ohne entsprechenden Datenbankeintrag existiert oder umgekehrt.

### Eindeutige Zertifikate mit OCSP-Prüfung

{% tabs %}
{% tab title="Log Ingestion API ( Standard )" %}

```kusto
let map_certtype = datatable(serial_start:string, readable:string)
[
  "40", "Intune-Gerät",
  "41", "Intune-Gerät",
  "42", "Intune-inkompatibles Gerät",
  "50", "Statisch",
  "51", "Statisch",
  "60", "Intune-Benutzer",
  "61", "Intune-Benutzer",
  "64", "Jamf-Benutzer",
  "65", "Jamf-Benutzer",
  "6C", "Jamf-Benutzer auf Gerät",
  "6D", "Jamf-Benutzer auf Gerät",
  "70", "Domain Controller",
  "7C", "Jamf-Benutzer auf Computer",
  "7D", "Jamf-Benutzer auf Computer",
  "54", "Jamf-Computer",
  "55", "Jamf-Computer",
  "44", "Jamf-Gerät",
  "45", "Jamf-Gerät"
];
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="Data Collector API ( Alt )" %}

```kql
let map_certtype = datatable(serial_start:string, readable:string)
[
  "40", "Intune-Gerät",
  "41", "Intune-Gerät",
  "42", "Intune-inkompatibles Gerät",
  "50", "Statisch",
  "51", "Statisch",
  "60", "Intune-Benutzer",
  "61", "Intune-Benutzer",
  "64", "Jamf-Benutzer",
  "65", "Jamf-Benutzer",
  "6C", "Jamf-Benutzer auf Gerät",
  "6D", "Jamf-Benutzer auf Gerät",
  "70", "Domain Controller",
  "7C", "Jamf-Benutzer auf Computer",
  "7D", "Jamf-Benutzer auf Computer",
  "54", "Jamf-Computer",
  "55", "Jamf-Computer",
  "44", "Jamf-Gerät",
  "45", "Jamf-Gerät"
];
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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
