swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: API to Add/Remove/List Guest Diagnostics Configuration to Azure Resources
  title: Guest Diagnostic Settings
  version: 2018-06-01-preview
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-ms-code-generation-settings:
    name: MonitorManagementClient
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/guestDiagnosticSettings_API.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: monitor-guestDiagnosticSettings_API
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
security:
  - azure_auth:
      - user_impersonation
parameters:
  ApiVersionParameter:
    description: Client Api Version.
    in: query
    name: api-version
    required: true
    type: string
  DiagnosticSettingNameParameter:
    description: The name of the diagnostic setting.
    in: path
    name: diagnosticSettingsName
    required: true
    type: string
    x-ms-parameter-location: method
  ResourceGroupNameParameter:
    description: The name of the resource group.
    in: path
    name: resourceGroupName
    required: true
    type: string
    x-ms-parameter-location: method
  SubscriptionIdParameter:
    description: The Azure subscription Id.
    in: path
    name: subscriptionId
    required: true
    type: string
paths:
  "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings":
    get:
      description: Get a list of all guest diagnostic settings in a subscription.
      operationId: guestDiagnosticsSettings_List
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: The request succeeded.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsList"
        default:
          description: An error occurred and the list of guest diagnostic settings could not be retrieved.
          schema:
            $ref: "#/definitions/ErrorResponse"
      x-ms-pageable:
        nextLinkName: null
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings":
    get:
      description: Get a list of all guest diagnostic settings in a resource group.
      operationId: guestDiagnosticsSettings_ListByResourceGroup
      parameters:
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: The request succeeded.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsList"
        default:
          description: An error occurred and the list of guest diagnostic settings could not be retrieved.
          schema:
            $ref: "#/definitions/ErrorResponse"
      x-ms-pageable:
        nextLinkName: null
  "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}":
    delete:
      description: Delete guest diagnostics settings.
      operationId: guestDiagnosticsSettings_Delete
      parameters:
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/DiagnosticSettingNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: The diagnostic settings was successfully deleted.
        "204":
          description: The diagnostic settings does not exist. It may have already been deleted.
        default:
          description: An error occurred and the diagnostic settings could not be deleted.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - GuestDiagnosticsSettings
    get:
      description: Gets guest diagnostics settings.
      operationId: guestDiagnosticsSettings_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/DiagnosticSettingNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: The request succeeded.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
        default:
          description: An error occurred and the diagnostic settings could not be retrieved.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - GuestDiagnosticsSettings
    patch:
      description: Updates guest diagnostics settings.
      operationId: guestDiagnosticsSettings_Update
      parameters:
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/DiagnosticSettingNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - description: The configuration to patch.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsPatchResource"
      responses:
        "200":
          description: An existing guest diagnostic settings was successfully updated.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
        "201":
          description: A new guest diagnostic settings was successfully created.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
        default:
          description: An error occurred and the guest diagnostic settings could not be created or updated.
          schema:
            $ref: "#/definitions/ErrorResponse"
    put:
      description: Creates or updates guest diagnostics settings.
      operationId: guestDiagnosticsSettings_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/DiagnosticSettingNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - description: The configuration to create or update.
          in: body
          name: diagnosticSettings
          required: true
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
      responses:
        "200":
          description: An existing guest diagnostic settings was successfully updated.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
        "201":
          description: A new guest diagnostic settings was successfully created.
          schema:
            $ref: "#/definitions/GuestDiagnosticSettingsResource"
        default:
          description: An error occurred and the guest diagnostic settings could not be created or updated.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - GuestDiagnosticsSettings
      x-ms-examples:
        Create or update a guest diagnostic settings:
          parameters:
            api-version: 2018-06-01-preview
            diagnosticSettings:
              location: Global
              properties:
                dataSources:
                  - configuration:
                      perfCounters:
                        - name: \Process(_Total)\%Processor Time
                          samplingPeriod: PT1M
                        - name: \Process(_Total)\Working Set
                          samplingPeriod: PT1M
                    kind: PerformanceCounter
                    sinks:
                      - kind: LogAnalytics
                  - configuration:
                      providers:
                        - filter: filter exp
                          id: 1
                          name: AuditLog
                        - id: 2
                          name: TraceLog
                    kind: ETWProviders
                    sinks:
                      - kind: LogAnalytics
                  - configuration:
                      eventLogs:
                        - filter: SourceName == Xyz AND EventId = "100" AND  $Xpath/Column="DCName" = "CatWoman"
                          logName: Application
                        - filter: SourceName == Xyz AND EventId = "100" AND  $Xpath/Column="DCName" = "BatMan"
                          logName: Application
                    kind: WindowsEventLogs
                    sinks:
                      - kind: LogAnalytics
                osType: Windows
              tags: {}
            diagnosticSettingsName: SampleDiagSetting
            resourceGroupName: Default-ResourceGroup
            subscriptionId: 187f412d-1758-44d9-b052-169e2564721d
          responses:
            "200":
              body:
                id: /subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/Default-ResourceGroup/providers/microsoft.insights/guestDiagnosticSettings/SampleDiagSetting
                location: West US
                name: productionMachineSetting
                properties:
                  dataSources:
                    - configuration:
                        perfCounters:
                          - name: \Process(_Total)\%Processor Time
                            samplingPeriod: PT1M
                          - name: \Process(_Total)\Working Set
                            samplingPeriod: PT1M
                      kind: PerformanceCounter
                      sinks:
                        - kind: LogAnalytics
                  osType: Windows
                tags: {}
                type: Microsoft.Insights/guestDiagnosticSettings
              headers: {}
            "201":
              body:
                id: /subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/Default-ResourceGroup/providers/microsoft.insights/guestDiagnosticSettings/SampleDiagSetting
                location: West US
                name: SampleDiagSetting
                properties:
                  dataSources:
                    - configuration:
                        perfCounters:
                          - name: \Process(_Total)\%Processor Time
                            samplingPeriod: PT1M
                          - name: \Process(_Total)\Working Set
                            samplingPeriod: PT1M
                      kind: PerformanceCounter
                      sinks:
                        - kind: LogAnalytics
                  osType: Windows
                tags: {}
                type: Microsoft.Insights/guestDiagnosticSettings
              headers: {}
definitions:
  DataSource:
    description: Data source object contains configuration to collect telemetry and one or more sinks to send that telemetry data to
    properties:
      configuration:
        $ref: "#/definitions/DataSourceConfiguration"
        type: object
      kind:
        description: Datasource kind
        enum:
          - PerformanceCounter
          - ETWProviders
          - WindowsEventLogs
        type: string
      sinks:
        items:
          $ref: "#/definitions/SinkConfiguration"
        type: array
    required:
      - kind
      - configuration
      - sinks
    type: object
  DataSourceConfiguration:
    properties:
      eventLogs:
        description: Windows event logs configuration.
        items:
          $ref: "#/definitions/EventLogConfiguration"
        type: array
      perfCounters:
        description: Performance counter configuration
        items:
          $ref: "#/definitions/PerformanceCounterConfiguration"
        type: array
      providers:
        description: ETW providers configuration
        items:
          $ref: "#/definitions/EtwProviderConfiguration"
        type: array
    type: object
  ErrorResponse:
    description: Describes the format of Error response.
    properties:
      code:
        description: Error code
        type: string
      message:
        description: Error message indicating why the operation failed.
        type: string
    type: object
  EtwEventConfiguration:
    properties:
      filter:
        type: string
      id:
        type: integer
      name:
        type: string
    required:
      - name
      - id
    type: object
  EtwProviderConfiguration:
    properties:
      events:
        items:
          $ref: "#/definitions/EtwEventConfiguration"
        type: array
      id:
        type: string
    required:
      - id
      - events
    type: object
  EventLogConfiguration:
    properties:
      filter:
        type: string
      logName:
        type: string
    required:
      - logName
    type: object
  GuestDiagnosticSettings:
    description: Virtual machine diagnostic settings
    properties:
      dataSources:
        description: the array of data source object which are configured to collect and send data
        items:
          $ref: "#/definitions/DataSource"
        type: array
      osType:
        description: Operating system type for the configuration
        enum:
          - Windows
          - Linux
        type: string
      proxySetting:
        type: string
  GuestDiagnosticSettingsList:
    description: A list of guest diagnostic settings.
    properties:
      nextLink:
        description: Provides the link to retrieve the next set of elements.
        type: string
      value:
        description: The list of guest diagnostic settings.
        items:
          $ref: "#/definitions/GuestDiagnosticSettingsResource"
        type: array
  GuestDiagnosticSettingsPatchResource:
    description: An diagnostic settings object for the body of patch operations.
    properties:
      properties:
        $ref: "#/definitions/GuestDiagnosticSettings"
        description: The diagnostic settings for an update operation.
        x-ms-client-flatten: true
      tags:
        additionalProperties:
          type: string
        description: Resource tags
  GuestDiagnosticSettingsResource:
    allOf:
      - $ref: "#/definitions/Resource"
    description: Virtual machine guest diagnostics settings resource.
    properties:
      properties:
        $ref: "#/definitions/GuestDiagnosticSettings"
        description: The diagnostic settings to be applied to azure resources.
        x-ms-client-flatten: true
    required:
      - properties
    type: object
  PerformanceCounterConfiguration:
    properties:
      instance:
        type: string
      name:
        type: string
      samplingPeriod:
        type: string
    required:
      - name
      - samplingPeriod
    type: object
  Resource:
    description: An azure resource object
    properties:
      id:
        description: Azure resource Id
        readOnly: true
        type: string
      location:
        description: Resource location
        type: string
        x-ms-mutability:
          - create
          - read
      name:
        description: Azure resource name
        readOnly: true
        type: string
      tags:
        additionalProperties:
          type: string
        description: Resource tags
      type:
        description: Azure resource type
        readOnly: true
        type: string
    required:
      - location
    x-ms-azure-resource: true
  SinkConfiguration:
    properties:
      kind:
        enum:
          - EventHub
          - ApplicationInsights
          - LogAnalytics
        type: string
    required:
      - kind
    type: object
