> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eorion.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 通过Id获取活动实例统计信息

> Retrieves runtime statistics of a given process definition, grouped by activities.
These statistics include the number of running activity instances, optionally the number of failed jobs
and also optionally the number of incidents either grouped by incident types or for a specific incident type.
**Note**: This does not include historic data.



## OpenAPI

````yaml GET /process-definition/{id}/statistics
openapi: 3.0.2
info:
  title: ORION Platform REST API
  description: OpenApi Spec for ORION Camunda Platform REST API.
  version: 7.22.6-ee
  license:
    name: Apache License 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: http://{host}:{port}/{contextPath}
    description: The API server for the default process engine
    variables:
      host:
        default: localhost
      port:
        default: '8080'
      contextPath:
        default: engine-rest
  - url: http://{host}:{port}/{contextPath}/engine/{engineName}
    description: The API server for a named process engine
    variables:
      host:
        default: localhost
      port:
        default: '8080'
      contextPath:
        default: engine-rest
      engineName:
        default: default
  - url: '{url}'
    description: The API server with a custom url
    variables:
      url:
        default: ''
security:
  - basicAuth: []
tags:
  - name: Authorization
  - name: Batch
  - name: Condition
  - name: Decision Definition
  - name: Decision Requirements Definition
  - name: Deployment
  - name: Engine
  - name: Event Subscription
  - name: Execution
  - name: External Task
  - name: Filter
  - name: Group
  - name: Historic Activity Instance
  - name: Historic Batch
  - name: Historic Decision Definition
  - name: Historic Decision Instance
  - name: Historic Decision Requirements Definition
  - name: Historic Detail
  - name: Historic External Task Log
  - name: Historic Identity Link Log
  - name: Historic Incident
  - name: Historic Job Log
  - name: Historic Process Definition
  - name: Historic Process Instance
  - name: Historic Task Instance
  - name: Historic User Operation Log
  - name: Historic Variable Instance
  - name: History Cleanup
  - name: Identity
  - name: Incident
  - name: Job
  - name: Job Definition
  - name: Message
  - name: Metrics
  - name: Migration
  - name: Modification
  - name: Process Definition
  - name: Process Instance
  - name: Signal
  - name: Schema Log
  - name: Task
  - name: Task Attachment
  - name: Task Comment
  - name: Task Identity Link
  - name: Task Local Variable
  - name: Task Variable
  - name: Telemetry
  - name: Tenant
  - name: User
  - name: Variable Instance
  - name: Version
externalDocs:
  description: Find out more about ORION Rest API
  url: https://docs.eorion.com
paths:
  /process-definition/{id}/statistics:
    get:
      tags:
        - Process Definition
      summary: Get Activity Instance Statistics
      description: >-
        Retrieves runtime statistics of a given process definition, grouped by
        activities.

        These statistics include the number of running activity instances,
        optionally the number of failed jobs

        and also optionally the number of incidents either grouped by incident
        types or for a specific incident type.

        **Note**: This does not include historic data.
      operationId: getActivityStatistics
      parameters:
        - name: id
          in: path
          schema:
            type: string
          required: true
          description: The id of the process definition.
        - name: failedJobs
          in: query
          schema:
            type: boolean
          description: >-
            Whether to include the number of failed jobs in the result or not.
            Valid values are `true` or `false`.
        - name: incidents
          in: query
          schema:
            type: boolean
          description: >-
            Valid values for this property are `true` or `false`.

            If this property has been set to `true` the result will include the
            corresponding number of incidents

            for each occurred incident type.

            If it is set to `false`, the incidents will not be included in the
            result.

            Cannot be used in combination with `incidentsForType`.
        - name: incidentsForType
          in: query
          schema:
            type: string
          description: >-
            If this property has been set with any incident type (i.e., a string
            value) the result

            will only include the number of incidents for the assigned incident
            type.

            Cannot be used in combination with `incidents`.

            See the [User
            Guide](https://docs.camunda.org/manual/7.22/user-guide/process-engine/incidents/#incident-types)

            for a list of incident types.
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ActivityStatisticsResultDto'
              examples:
                example-1:
                  summary: >-
                    GET
                    /process-definition/aProcessDefinitionId/statistics?failedJobs=true
                  description: Request with Query Parameter `failedJobs=true`
                  value:
                    - '@class': >-
                        org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto
                      id: anActivity
                      instances: 123
                      failedJobs: 42
                      incidents: []
                    - '@class': >-
                        org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto
                      id: anotherActivity
                      instances: 124
                      failedJobs: 43
                      incidents: []
                example-2:
                  summary: >-
                    GET
                    /process-definition/aProcessDefinitionId/statistics?incidents=true
                  description: Request with Query Parameter `incidents=true`
                  value:
                    - '@class': >-
                        org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto
                      id: anActivity
                      instances: 123
                      failedJobs: 0
                      incidents:
                        - incidentType: failedJob
                          incidentCount: 42
                        - incidentType: anIncident
                          incidentCount: 20
                    - '@class': >-
                        org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto
                      id: anotherActivity
                      instances: 124
                      failedJobs: 0
                      incidents:
                        - incidentType: failedJob
                          incidentCount: 43
                        - incidentType: anIncident
                          incidentCount: 22
                        - incidentType: anotherIncident
                          incidentCount: 15
                example-3:
                  summary: >-
                    GET
                    /process-definition/aProcessDefinitionId/statistics?incidentsForType=anIncident
                  description: Request with Query Parameter `incidentsForType=anIncident`
                  value:
                    - '@class': >-
                        org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto
                      id: anActivity
                      instances: 123
                      failedJobs: 0
                      incidents:
                        - incidentType: anIncident
                          incidentCount: 20
          description: Request successful.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExceptionDto'
          description: >-
            Returned if some of the query parameters are invalid.

            See the

            [Introduction](https://docs.camunda.org/manual/7.22/reference/rest/overview/#error-handling)

            for the error response format.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExceptionDto'
          description: >-
            Process definition with given key does not exist.

            See the

            [Introduction](https://docs.camunda.org/manual/7.22/reference/rest/overview/#error-handling)

            for the error response format.
components:
  schemas:
    ActivityStatisticsResultDto:
      type: object
      properties:
        id:
          type: string
          nullable: true
          description: The id of the activity the results are aggregated for.
        instances:
          type: integer
          format: int32
          description: The total number of running process instances of this activity.
        failedJobs:
          type: integer
          format: int32
          description: |-
            The total number of failed jobs for the running instances.
            **Note**: Will be `0` (not `null`), if failed jobs were excluded.
        incidents:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/IncidentStatisticsResultDto'
          description: >-
            Each item in the resulting array is an object which contains
            `incidentType` and `incidentCount`.

            **Note**: Will be an empty array, if `incidents` or
            `incidentsForType` were excluded.

            Furthermore, the array will be also empty if no incidents were
            found.
        '@class':
          type: string
          nullable: true
          description: |-
            The fully qualified class name of the data transfer object class.
            The class name might change in future releases.
    ExceptionDto:
      title: ExceptionDto
      type: object
      properties:
        type:
          type: string
          nullable: true
          description: An exception class indicating the occurred error.
        message:
          type: string
          nullable: true
          description: A detailed message of the error.
        code:
          type: number
          description: >-
            The code allows your client application to identify the error in an
            automated fashion.

            You can look up the meaning of all built-in codes and learn how to
            add custom codes

            in the [User
            Guide](https://docs.camunda.org/manual/7.22/user-guide/process-engine/error-handling/#exception-codes).
    IncidentStatisticsResultDto:
      type: object
      properties:
        incidentType:
          type: string
          nullable: true
          description: >-
            The type of the incident the number of incidents is aggregated for.

            See the [User
            Guide](https://docs.camunda.org/manual/7.22/user-guide/process-engine/incidents/#incident-types)
            for a list of incident types.
        incidentCount:
          type: integer
          format: int32
          nullable: true
          description: The total number of incidents for the corresponding incident type.
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````