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

# Count cluster log lines by field

> The matching log lines of the window counted by each field asked for (level, pod, or a key of the application's record), in the store the history query reads, with the same source choice and the log volume count's filters. Level is counted by the log volume count's rule. A field the store cannot group by is answered not_counted with a reason and a sentence, never as no values; a list cut at 100 values says so. A store that fails any field's read answers an error, never fields without values.

This is the API-token route. It requires `kubernetes.logs` on the cluster, and a token's scopes narrow it.



## OpenAPI

````yaml https://platform.ankra.app/openapi.json post /api/v1/org/clusters/imported/{cluster_id}/logs/fields
openapi: 3.1.0
info:
  title: Ankra Platform API
  version: v1
  description: >-
    The Ankra platform HTTP contract. The /api/v1 surface is the public,
    bearer-authenticated API used by the Ankra CLI, MCP clients and automation;
    send a personal or service API token as `Authorization: Bearer <token>`.
    Browser routes under /org and /chat are served on api.platform.ankra.app
    (each declares that server); they and /oauth/access authenticate with the
    ankra_session cookie, and mutations also require the X-Ankra-CSRF header.
    Every operation declares the credential it accepts. Only the public platform
    status feed (GET /api/v1/status) is served without one. This document is
    published deliberately: it describes the contract only and carries no
    organisation data or credentials. Report security issues to
    security@ankra.ai (see /.well-known/security.txt).
servers:
  - url: https://platform.ankra.app
security:
  - BearerAuth: []
tags:
  - name: Onboarding
    description: >-
      Generate a first website from a prompt and deploy it to a new
      organisation's cluster.
  - name: Access Gate
    description: >-
      Private service sign-in and membership checks for trusted Ankra proxy
      relays.
  - name: Canvas Datasets
    description: >-
      Read the fixed, named datasets canvas dashboards bind their charts, tables
      and stats to.
  - name: Canvases
    description: >-
      Keep dashboards and pages in the organisation's canvas library, with
      revision history, undo and pins.
  - name: Canvas Pages
    description: >-
      Publish a chat canvas artifact at a public pages address and take it down
      again.
  - name: Cloud Delegation
    description: >-
      Platform browser consent and organisation-bound connections for Ankra
      Cloud.
  - name: Organisation IAM
    description: >-
      Custom organisation roles and scoped role assignments for member and
      service-account identities.
  - name: Clusters
    description: Create, inspect and manage clusters, and the stacks deployed on them.
  - name: Managed Clusters
    description: Provider-managed control planes, driven through one common surface.
  - name: Playground
    description: >-
      The organisation's playground cluster: order one, read its provisioning
      status, list the orderable sizes, resize it and destroy it.
  - name: Imported Clusters
    description: Clusters that already existed and were connected to Ankra.
  - name: Cluster Access
    description: Kubeconfigs, service-account tokens and per-cluster access grants.
  - name: Cluster Meshes
    description: >-
      Cilium ClusterMeshes that join an organisation's clusters into one
      network: create a mesh, check whether clusters can join, prepare a running
      cluster, and add or remove members.
  - name: Kubernetes
    description: Read and act on the Kubernetes objects inside a cluster.
  - name: AWS Clusters
    description: >-
      Provision and manage self-managed k3s / kubeadm clusters on AWS EC2 in
      your own VPC.
  - name: Ankra Cloud Clusters
    description: >-
      Provision and manage self-managed kubeadm / k3s clusters on Ankra Cloud
      servers: a private network, a NAT router and a bastion per cluster.
  - name: DigitalOcean Clusters
    description: Provision and manage DigitalOcean Kubernetes clusters.
  - name: Hetzner Clusters
    description: Provision and manage Hetzner Kubernetes clusters.
  - name: OVH Clusters
    description: Provision and manage OVH Kubernetes clusters.
  - name: Scaleway Clusters
    description: Provision and manage Scaleway Kapsule clusters.
  - name: UpCloud Clusters
    description: Provision and manage UpCloud Kubernetes clusters.
  - name: Proxmox Clusters
    description: >-
      Self-managed Kubernetes clusters Ankra builds on Proxmox VE VMs: the node,
      storage, bridge, template and size catalogs, create and teardown, start
      and stop, node groups, nodes, standalone VMs, upgrades and the bastion.
  - name: HPE Morpheus Clusters
    description: >-
      Self-managed Kubernetes clusters Ankra builds on HPE Morpheus VMs: the
      group, cloud, plan, layout and network catalogs, create and teardown,
      start and stop, node groups, nodes, standalone VMs, upgrades and the
      bastion.
  - name: Applications
    description: Deploy, configure and observe applications across the fleet.
  - name: Pipelines
    description: >-
      Pipeline definitions, the approval of the authority they declare, and the
      caches pipelines keep between runs.
  - name: Workspaces
    description: >-
      Personal workspaces on the organisation's CI pool where a repository's
      heavy commands run, and the repository profiles they are built from.
  - name: Deploy Targets
    description: >-
      Environments, the hosts registered to receive deployments, and the
      releases deployed to them.
  - name: Deploy Provenance
    description: >-
      Whether an application's deploys verify signed provenance from the
      organisation's own pipeline, the keys that provenance is signed with, and
      a dry-run that verifies images without deploying.
  - name: Backups
    description: >-
      Backup vaults, restore points, protection posture and captures for stacks
      and application deployments; a completed capture is not a verified
      restore.
  - name: Stack Profiles
    description: Reusable stack definitions, their versions and sharing.
  - name: Services
    description: >-
      Versioned service packages and explicit sharing. Runtime admission is
      separate from publication.
  - name: Charts
    description: Browse the chart catalogue behind stacks and addons.
  - name: Helm
    description: Helm registries, credentials and the charts they expose.
  - name: Executions
    description: Long-running platform executions and their jobs.
  - name: Operations
    description: Cancel in-flight cluster operations and their jobs.
  - name: Chat
    description: Conversational sessions, plans and confirmable actions.
  - name: AI Management
    description: >-
      Customer agent lifecycle, authenticated identity and organisation
      automation controls.
  - name: AI Agent Runs
    description: Autonomous agent runs and their outcomes.
  - name: AI Tickets
    description: The AI ticket board, its sync connections and settings.
  - name: AI Playbooks
    description: Reusable playbooks the AI lanes execute.
  - name: AI Conditions
    description: Conditions that gate AI autonomy.
  - name: AI Remediation
    description: >-
      The organisation's auto-remediation policy: what the AI lanes may fix by
      themselves, and who approves the rest.
  - name: AI Engineering Handoffs
    description: Work the AI lanes escalate to a human engineer.
  - name: AI Environment
    description: The environment and base stacks AI demos deploy into.
  - name: AI Memory
    description: >-
      What the assistant has learned about you: your cross-session memories and
      learned profile.
  - name: MCP Servers
    description: >-
      Register the MCP servers the organisation's AI agents can call, choose
      their tools and grant them to roles.
  - name: Security
    description: Findings, advisories, SBOMs, compliance and posture.
  - name: Cost
    description: Cluster and fleet cost, rate cards and cost settings.
  - name: Decisions
    description: >-
      The decision ledger behind the Security and Cost queues: proposals a
      surface computed, the approve and set-aside decisions people took on them,
      and the receipts of running them.
  - name: Usage
    description: >-
      What your organisation used of Ankra - vCPU-hours, playgrounds, managed
      services, hosted logs and metrics, and AI - per meter and period, with how
      completely it was measured and whether a published rate applies.
  - name: Billing
    description: Subscription and spend caps.
  - name: Organisation
    description: Members, invitations, audit logs and organisation settings.
  - name: Projects
    description: >-
      Projects group an organisation's clusters, applications, credentials and
      other resources beneath it: list, create, rename and delete them, switch
      the current project, see who reaches one, and move resources between them.
  - name: Account
    description: >-
      Your own account: the contact email Ankra mails when it differs from your
      sign-in address, and the AI provider keys your own work runs on.
  - name: Account Tokens
    description: Personal access tokens for the API and CLI.
  - name: Credentials
    description: The shared credential store.
  - name: AWS Credentials
    description: >-
      AWS credentials: access keys or CloudFormation-onboarded STS roles for
      cost, EKS and self-managed provisioning.
  - name: Ankra Cloud Credentials
    description: >-
      Ankra Cloud API tokens, shared by the self-managed and managed Ankra Cloud
      lanes.
  - name: Azure Credentials
    description: Azure credentials and SSH keys.
  - name: DigitalOcean Credentials
    description: DigitalOcean credentials and SSH keys.
  - name: Hetzner Credentials
    description: Hetzner credentials and SSH keys.
  - name: HPE Morpheus Credentials
    description: HPE Morpheus credentials and the capacity and quotas behind them.
  - name: OVH Credentials
    description: OVH credentials and SSH keys.
  - name: Proxmox Credentials
    description: Proxmox VE credentials and the capacity and quotas behind them.
  - name: Scaleway Credentials
    description: Scaleway credentials.
  - name: UpCloud Credentials
    description: UpCloud credentials and SSH keys.
  - name: Data Source Credentials
    description: Credentials for metrics and log sources.
  - name: DNS Credentials
    description: Credentials for DNS providers.
  - name: Object Storage Buckets
    description: >-
      Buckets Ankra creates and manages on an organisation's own provider
      credentials.
  - name: DNS
    description: DNS zones and records, including custom organisation zones.
  - name: Cloudflare
    description: Cloudflare domains and the credentials behind them.
  - name: Avura
    description: >-
      The linked Avura organization, the domains it shares with Ankra Platform,
      and their DNS records.
  - name: Variables
    description: Organisation- and cluster-scoped variables.
  - name: Secret Slots
    description: >-
      Store secrets in Vault and reference them by ${SECRET_SLOT:<slot_id>}
      sentinel instead of by value.
  - name: SOPS
    description: Encrypt and decrypt values with the organisation SOPS config.
  - name: Alerts
    description: Alert integrations and ingest credentials.
  - name: Notifications
    description: Notification routes and their delivery targets.
  - name: Platform Status
    description: >-
      The public status of the Ankra platform: incidents and maintenance Ankra
      staff publish, as shown on ankra.ai/status.
  - name: Support
    description: Support tickets.
  - name: AI Settings
    description: Organisation AI provider, model catalog and per-function model settings
paths:
  /api/v1/org/clusters/imported/{cluster_id}/logs/fields:
    post:
      tags:
        - Clusters
      summary: Count cluster log lines by field
      description: >-
        The matching log lines of the window counted by each field asked for
        (level, pod, or a key of the application's record), in the store the
        history query reads, with the same source choice and the log volume
        count's filters. Level is counted by the log volume count's rule. A
        field the store cannot group by is answered not_counted with a reason
        and a sentence, never as no values; a list cut at 100 values says so. A
        store that fails any field's read answers an error, never fields without
        values.


        This is the API-token route. It requires `kubernetes.logs` on the
        cluster, and a token's scopes narrow it.
      operationId: count_cluster_selected_log_fields_pat
      parameters:
        - description: PAT organisation override.
          in: header
          name: x-ankra-organisation-id
          required: false
          schema:
            type: string
        - in: path
          name: cluster_id
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClusterLogFieldsQuery'
      responses:
        '200':
          description: The matching lines counted by each field
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusterLogFieldsResult'
        '400':
          description: >-
            Unsupported source choice or window, a field list the read cannot
            count, a raw query, or a level, min_level, cursor or step_seconds,
            which the field counts refuse
        '401':
          description: Unknown, expired, or revoked API token
        '403':
          description: Cluster log read permission denied
        '404':
          description: No connected source for the requested choice
        '422':
          description: Request validation error
        '502':
          description: The store's reply could not be read
        '503':
          description: Selected store or cluster unavailable
        '504':
          description: The store did not answer in time
      security:
        - BearerAuth: []
components:
  schemas:
    ClusterLogFieldsQuery:
      type: object
      required:
        - fields
      properties:
        fields:
          type: array
          minItems: 1
          maxItems: 8
          items:
            type: string
          description: >-
            The fields to count, each once: level, pod, or record.<key> for a
            key of the application's record (letters, digits, '_', '-', '@' and
            dots between words, at most 128 characters). version is refused:
            count by pod and add up the pods of each version.
        start:
          type: string
        end:
          type: string
        since:
          type: string
        search:
          type: string
        raw_query:
          type: string
          description: >-
            Refused with 400 whenever it names a value: the store cannot count a
            raw query by field with the count's rule. Use the structured
            filters.
        namespaces:
          type: array
          items:
            type: string
        pods:
          type: array
          items:
            type: string
        containers:
          type: array
          items:
            type: string
        levels:
          type: array
          items:
            type: string
            enum:
              - error
              - warn
              - info
              - debug
              - other
          maxItems: 100
          description: >-
            Count only the lines of these level classes, as the log volume count
            reads them. Refused with 400 as on the count.
        exclude:
          type: object
          additionalProperties: false
          description: >-
            Lines to leave out of every field's count, as the log volume count
            leaves them out. Refused with 400 for a key other than pods, levels
            and words.
          properties:
            pods:
              type: array
              items:
                type: string
              maxItems: 100
              description: Leave out the lines of these pods (exact names).
            levels:
              type: array
              items:
                type: string
                enum:
                  - error
                  - warn
                  - info
                  - debug
                  - other
              maxItems: 100
              description: Leave out the lines of these level classes.
            words:
              type: array
              items:
                type: string
              maxItems: 100
              description: >-
                Leave out the lines whose message holds one of these words,
                found the way search finds a word.
        source:
          type: string
          enum:
            - auto
            - connected
            - ankra_hosted
          default: auto
          description: >-
            The same source choice as the history query, so the counts and the
            lines come from one store.
        level:
          description: >-
            Refused with 400 whenever it names a value: use levels, the level
            classes the count reads.
        min_level:
          description: >-
            Refused with 400 whenever it names a value: use levels, the level
            classes the count reads.
        cursor:
          description: >-
            Refused with 400 whenever it names a value: the counts cover the
            whole window.
        step_seconds:
          description: >-
            Refused with 400 whenever it names a value: the counts cover the
            whole window.
    ClusterLogFieldsResult:
      type: object
      properties:
        provider:
          type: string
        source:
          type: string
          description: >-
            ankra_hosted when Ankra hosted logs answered; absent for a connected
            source.
        note:
          type: string
        cluster_attribution:
          type: object
          additionalProperties: true
        start:
          type: string
          description: >-
            The window's start, taken down to the whole second as on the log
            volume count.
        end:
          type: string
          description: >-
            The window's end, taken up to the whole second as on the log volume
            count.
        kept_days:
          type:
            - integer
            - 'null'
          description: >-
            The most days the store keeps a line: 7 for Ankra hosted logs, and
            null for a store of your own.
        value_limit:
          type: integer
          description: 'The most values one field lists: 100.'
        fields:
          type: array
          description: Every field asked for, in the order asked.
          items:
            $ref: '#/components/schemas/ClusterLogFieldCount'
    ClusterLogFieldCount:
      type: object
      properties:
        field:
          type: string
          description: The field as it was asked for.
        state:
          type: string
          enum:
            - counted
            - not_counted
          description: >-
            counted when the store grouped the matching lines by the field;
            not_counted when it cannot, and then values is null, never an empty
            list.
        reason:
          type:
            - string
            - 'null'
          enum:
            - hosted_line_is_text
            - loki_line_is_text
            - not_keyword_field
            - field_not_held
            - null
          description: Why the field was not counted; null when it was.
        note:
          type:
            - string
            - 'null'
          description: reason in plain words; null when the field was counted.
        store_field:
          type: string
          description: >-
            The store's own field or label the values were grouped by. Absent
            for level, which is counted by the log volume count's rule.
        values:
          type:
            - array
            - 'null'
          description: >-
            The field's values that matching lines hold, the most lines first,
            at most value_limit. Null when the field was not counted.
          items:
            type: object
            properties:
              value:
                type: string
              count:
                type: integer
        value_limit:
          type: integer
          description: 'The most values one field lists: 100.'
        values_capped:
          type: boolean
          description: True when the field has more values than are listed.
        distinct_values:
          type:
            - integer
            - 'null'
          description: >-
            How many values the field has among the matching lines. Null when
            the store cannot say exactly (a capped list on Elasticsearch or
            OpenSearch) or the field was not counted.
        lines_without_value:
          type:
            - integer
            - 'null'
          description: >-
            Matching lines that hold no value of the field. Null when it was not
            read: a capped list on VictoriaLogs or Loki, or a field not counted.
        counts_are_exact:
          type: boolean
          description: >-
            True when every count is the store's exact count over the window.
            False when the store says a count may be under (an Elasticsearch or
            OpenSearch terms count over several shards), and for a field not
            counted.
        own_filter_applied:
          type: boolean
          description: >-
            True when the request also filtered by this field (pods for pod;
            levels or exclude.levels for level), so the values are only those
            the filter kept. A page that shows every value beside a filter asks
            for that field without its own filter.
  securitySchemes:
    BearerAuth:
      bearerFormat: PAT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.