Service accounts and alert run-as
Create service accounts, issue their tokens, choose who an alert runs as, and fix alerts that have no usable run-as identity.
Service accounts and alert run-as
A service account is an identity for automation in one account. It holds roles like a user, but it cannot sign in. Alerts run their query, and send their notifications, as a run-as identity, never as the system. Open service accounts under Settings → Account → Service accounts.
Choose who an alert runs as
The alert editor's Runs as field offers three choices:
| Choice | Runs with | Who may choose it |
|---|---|---|
| Account default | The account's default service account, whichever it is when the alert runs | Holders of service_account.run_as on the default service account |
| Me (the author) | Your own access to tables and people | Any user who may save the alert |
| Service account: name | What both that service account and the person who chose it can do | Holders of service_account.run_as on it |
Saving checks that the identity can read every table and column the query uses and can notify every recipient. An alert
that runs as a service account, or as the account default, also records who chose it, and runs with only what both the
service account and that person can do at the time of the run. Each run also checks that person is still enabled and
still holds service_account.run_as and the service account's privileged permissions. Running as yourself, the alert
stops when you are disabled, removed from the account, or lose access to its tables.
Choosing a service account acts as it, so you also need everything it holds. Only a user chooses a run-as identity; agents and service accounts cannot.
Notifications follow the run-as identity
An alert only notifies people its run-as identity may notify, at save and at every run:
| Delivery | Needs, on the run-as identity |
|---|---|
| Notify a user | account_user.notify on that member. Users can always notify themselves. |
| Notify a group | group.notify on the group |
| Notify the whole account | account_user.notify across the account; each run notifies only members it may notify |
The Evaluator notifier role grants both across the account; Evaluator editor and Account administrator include them. A service account that reads data cannot email it to anyone until it is granted notify, so its notifications are bounded by what it can read and who it may tell.
The default service account
Each new account gets a default service account, Account default, holding Data reader and Evaluator notifier on
the account. The account setting Logship.Authz.CreateDefaultServiceAccounts controls it:
true(the default, and for accounts without the setting): turning it on creates the default service account when the account has none. When the original Account default still exists, it becomes the default again, which needs acting as it, as making any service account the default does.false: no default service account is created. Turning it off keeps an existing one.
Every change of an account setting is recorded in the account's audit log. Make another service account the default from
its page (needs account.manage_settings and acting as it); the default cannot be deleted.
Provisioned built-in alerts run as the account default and show Run-as needs review in the alerts list, and a Needs review warning in the editor, until someone who may choose the default saves them.
Alerts with no usable run-as identity
An alert whose identity resolves to nothing does not run. This is not an account error: the alert is skipped, its status shows No run-as identity with the reason, and nothing runs as the system instead. Causes and fixes:
| Cause | Fix |
|---|---|
| Account default chosen, but the account has no default service account | Make a service account the default, set Logship.Authz.CreateDefaultServiceAccounts to true, or choose another identity |
| The service account is disabled or deleted | Enable it, or choose another identity |
The person who chose the identity is disabled, gone, or lost service_account.run_as | Have someone who may choose it save the alert |
| Running as its author, who is disabled or removed | Choose another identity and save |
Alerts can be created and saved while they have no usable identity; they start running once they have one.
Create a service account for an alert
- In the alert editor, select Create service account with limited scope (shown with
service_account.create). The service accounts page opens in a new tab. - Name the service account and create it. You become its manager. It holds no access yet.
- On its page, under Roles held, select Grant access and grant it what the alert needs and nothing more: for example Data reader on only the tables the query reads, and Evaluator notifier if the alert sends notifications. Who can use and manage it controls who may choose, edit or view the service account.
- Return to the alert, choose the service account under Runs as, and save.
Issue a service account token
Automation outside alerts authenticates with a service account token, which acts with the service account's grants and nothing else.
- Open the service account and, under Tokens, select Issue token.
- Enter a Description of what uses it, and Expires (your local time), at most
jwt.apiTokenMaxLifetime(366 days by default) ahead. - Select Issue, copy the token, and select I have stored it. It is shown only once.
Issuing needs service_account.run_as on the service account and everything it holds. A service account token can do
only what both the service account and the person who issued it can do: losing a role narrows your tokens, and access
someone else gives the service account is not usable through them. The token stops working while you lose control of
the service account or its privileged permissions, are disabled, or change your password; mint a new one then
(service account tokens). Revoke it with Revoke token in the list.
Delete a service account
A service account that alerts run as cannot be deleted. The refusal lists the alerts you can view that run as it, and counts the others; choose another run-as identity for them first. Deleting revokes its tokens and removes everything granted to it.
An account holds at most 1,000 service accounts; creating another is refused until one is deleted. The list pages through those you can view.