> 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 verwenden SCEPman und der Certificate Master Microsofts Log Ingestion API, um Protokolle an Azure Monitor zu senden. Die Protokolle werden in einem Log Analytics Workspace gespeichert, und eine Data Collection Rule verbindet die App Services mit dem Workspace. Dieser moderne Ansatz verwendet RBAC-basierte Berechtigungen, damit SCEPman auf den Log Analytics Workspace zugreifen kann.

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

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

{% hint style="info" %}
Die **standardmäßige Aufbewahrungsdauer** für Daten, die in einer Log Analytics Table gespeichert sind, beträgt **30 Tage**. Falls ein anderer Aufbewahrungszeitraum erforderlich ist, passen Sie die Konfiguration der Tabelle "SCEPman\_CL" entsprechend an.
{% endhint %}

#### Erneutes Aktivieren der Data Collector API

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

Zu entfernende **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 der ausgestellten Zertifikate nach 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, werden als Breaking Changes betrachtet.
{% 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 %}

Seit SCEPman 2.8 gibt es pro ausgestelltem Zertifikat immer genau einen Protokolleintrag auf Info-Ebene, dessen Protokollmeldung mit "Issued a certificate with serial number " beginnt, gefolgt von der Seriennummer. Aufgrund des unlösbaren [Problem der zwei Armeen](https://en.wikipedia.org/wiki/Two_Generals'_Problem)kann es passieren, 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-nicht konformes Gerät",
  "50", "Statisch",
  "51", "Statisch",
  "60", "Intune-Benutzer",
  "61", "Intune-Benutzer",
  "64", "Jamf-Benutzer",
  "65", "Jamf-Benutzer",
  "6C", "Jamf-Benutzer auf dem Gerät",
  "6D", "Jamf-Benutzer auf dem Gerät",
  "70", "Domain Controller",
  "7C", "Jamf-Benutzer auf dem Computer",
  "7D", "Jamf-Benutzer auf dem 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-nicht konformes Gerät",
  "50", "Statisch",
  "51", "Statisch",
  "60", "Intune-Benutzer",
  "61", "Intune-Benutzer",
  "64", "Jamf-Benutzer",
  "65", "Jamf-Benutzer",
  "6C", "Jamf-Benutzer auf dem Gerät",
  "6D", "Jamf-Benutzer auf dem Gerät",
  "70", "Domain Controller",
  "7C", "Jamf-Benutzer auf dem Computer",
  "7D", "Jamf-Benutzer auf dem 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 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/de/azure-konfiguration/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.
