VictoriaLogs Authentication#
Overview#
The VictoriaLogs provider (victorialogs_provider.py) supports three authentication types β NoAuth, Basic, and Bearer β configured via the VictorialogsProviderAuthConfig dataclass.
Auth Config Fields#
All auth config is declared in VictorialogsProviderAuthConfig:
| Field | Type | Notes |
|---|---|---|
host_url | AnyHttpUrl | Required. Base URL of the VictoriaLogs instance. |
authentication_type | Literal["NoAuth", "Basic", "Bearer"] | Default: "NoAuth". Rendered as a select dropdown in the UI. |
username / password | Optional[str] | Used for Basic auth. password is marked sensitive. |
bearer_token | Optional[str] | Used for Bearer auth. Marked sensitive. |
x_scope_orgid | Optional[str] | Optional X-Scope-OrgID header, grouped under Bearer config. |
insecure | bool | Default False. When True, disables TLS verification on all requests. |
generate_auth_headers() Behavior#
generate_auth_headers() produces the HTTP headers passed to every request:
- Basic: Base64-encodes
username:passwordand returns{"Authorization": "Basic <encoded>"} - Bearer: Returns a dict with
Authorization: Bearer <token>and/orX-Scope-OrgID: <value>depending on which fields are set - NoAuth: No explicit
returnstatement β the function falls through and implicitly returnsNoneβ οΈ
Known Bug: NoAuth Returns None#
Status: Open bug with a fix in review β PR #6668.
When authentication_type is "NoAuth" (the default), generate_auth_headers() returns None instead of {}. Every query path in _query() then calls headers.update(...) on the result , raising:
AttributeError: 'NoneType' object has no attribute 'update'
This affects all four query types (query, hits, stats_query, stats_query_range) . The failure only appears at query time β the provider installs and validate_scopes() may pass because the scope check uses generate_auth_headers() without .update() .
Impact: A VictoriaLogs instance requiring no credentials cannot be queried at all with the default configuration.
Workaround: Select Basic auth and supply arbitrary credentials. Unauthenticated VictoriaLogs instances ignore the Authorization header .
Fix (PR #6668): Return {} from the NoAuth branch so downstream .update() calls succeed .
Usage in Queries#
_query() supports four queryType values, each posting to a different endpoint :
queryType | Endpoint |
|---|---|
query | /select/logsql/query |
hits | /select/logsql/hits |
stats_query | /select/logsql/stats_query |
stats_query_range | /select/logsql/stats_query_range |
For query and hits, the code merges auth headers with AccountID and ProjectID headers before sending . This merge is the direct call site of the None bug.
Key Files#
| File | Purpose |
|---|---|
keep/providers/victorialogs_provider/victorialogs_provider.py | Provider implementation, auth config, generate_auth_headers(), _query() |
tests/providers/victorialogs_provider/test_victorialogs_noauth.py | New test file added in PR #6668 covering all three auth types and NoAuth query behavior |