Service Accounts
A service account is a special kind of non-human account for applications, services, or virtual machines (VMs) to securely interact with other systems or APIs. Service accounts operate in the background, without user interaction.
For example, to programmatically download logs from Kloudfuse for analysis or archival, create a service account with specific permissions and use it to access the Kloudfuse API. Follow these steps:
-
Create a service account with a specific role: *Viewer*, *Editor*, or *Admin*.
-
Attach a policy to limit access.
For example, a policy
{kube_namespace="prometheus"}grants log access to the Prometheus namespace, only. -
Create an API token with an expiration date.
-
Use the token as a Bearer token in API calls to get and download logs.
Advantages
- Automation
-
Service accounts are purpose-built for automation, to be used by software, not people.
- Continuous Integration and Deployment
-
They are ideal for CI/CD pipelines, background jobs, or apps that access cloud services.
- Authentication and Authorization
-
Service accounts have their own credentials (keys, tokens, or certificates).
- Permissions
-
You can add specific permissions (roles or scopes) to limit access to only what the service account requires.
- Security
-
Service accounts provide secure, auditable access to APIs without exposing user credentials.
Navigate to Service Accounts List
Follow these steps to get to the Service Accounts interface:
-
Click the Admin tab, and then the Service Accounts option in the drop-down menu.
-
The Service Accounts interface appears.
Create a Service Account
To create a service account, follow these steps:
-
Click
(Create new service account).
-
The Create new service account interface appears.
-
Specify the new service account:
- Account name
-
Specify the name of the service account.
- Owner email
-
Specify the email that corresponds to the service account.
- Role
-
Specify the role for the service account: Viewer, Editor, or Admin.
-
Click
(Create).
-
Kloudfuse confirms that you successfully created a service account.
Set Query Priorities
The Query priority section on the service-account detail page lets you override the cluster-wide priority and per-call timeout for the Machine class. Service accounts run programmatic traffic only, so the Interactive class is not exposed here. See Override Priorities for a User, Team, or Service Account for instructions, and Query Priorities Concepts for the resolution model.
Examples
Use a service account to download logs
To create a service account for retrieving logs from Kloudfuse, and use it, follow these steps.
Create the service account
-
Navigate to Admin → Service Accounts.
-
Click Create new service account.
-
Specify the parameters:
- Account name
-
log-downloader - Owner email
-
automation@example.com - Role
-
Viewer(sufficient for read-only access to logs)
-
Click Create.
Attach a policy
After you create the service account, attach a policy that limits its access to what it needs:
-
Click the service account name.
-
Add a policy to restrict access. For example:
{kube_namespace="prometheus"}-
Grants access to logs from the
prometheusnamespace only. {kube_namespace="dd-trace-example"}-
Grants access to logs from the
dd-trace-examplenamespace only.
Create an API token
-
In the service account details, click Create Token.
-
Set an expiration date, for example 30 days, 90 days, or 1 year.
-
Copy the generated token.
-
Store the token securely. You can’t view it again after you close the dialog.
Use the token in API calls
Pass the token as a Bearer token in the Authorization header of each API call. This request downloads up to 2,000 log lines from a 5-minute window:
export KFUSE_HOST=<your-kloudfuse-hostname> (1)
export TOKEN=<service-account-token> (2)
curl "https://$KFUSE_HOST/query" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
--data-raw '{"query":"query GetLogsV2 { getLogsV2(cursor: null, query: {and: []}, limit: 2000, timestamp: \"2025-07-22T12:01:40-07:00\", durationSecs: 300, sortBy: \"ts\", sortOrder: Asc) { cursor events { timestamp logLine fpString fpHash level labels facets { name dataType content } } } }"}'
| 1 | KFUSE_HOST: the hostname of your Kloudfuse cluster. |
| 2 | TOKEN: the token you created in Create an API token. |
The response contains only the logs that the service account’s policy allows. With the {kube_namespace="prometheus"} policy, Kloudfuse returns only logs from the prometheus namespace:
{
"data": {
"getLogsV2": {
"cursor": "",
"events": [
{
"timestamp": "2025-07-22T19:00:03.171Z",
"logLine": "level=info ts=2025-07-22T19:00:02.381Z caller=compact.go:507 component=tsdb msg=\"write block\" duration=48.895847ms",
"level": "info",
"labels": {
"kube_namespace": "prometheus",
"pod_name": "prometheus-server-0",
...
}
}
]
}
}
}
Query APM services
The same token works with the PromQL query API. With the policy {kube_namespace="dd-trace-example"}, this request returns only the services in that namespace, not every service in the cluster:
curl -G "https://$KFUSE_HOST/api/v1/query" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode 'query=min(min_over_time(edge_latency_min{kf_source="apm",span_type!="db"}[5m])) by (service_hash, service_name)' \
--data-urlencode 'time=2025-07-22T18:43:38.000Z'