Mirantis Container Cloud (MCC) becomes part of Mirantis OpenStack for Kubernetes (MOSK)!
Starting with MOSK 25.2, the MOSK documentation set covers all product layers, including MOSK management (formerly Container Cloud). This means everything you need is in one place. Some legacy names may remain in the code and documentation and will be updated in future releases. The separate Container Cloud documentation site will be retired, so please update your bookmarks for continued easy access to the latest content.
StackLight provides a vast variety of metrics for MOSK
components. However, you may need to create a custom log-based metric to use it
for alert notifications, for example, in the following cases:
If a component producing logs does not expose scraping targets. In this case,
component-specific metrics may be missing.
If a scraping target lacks information that can be collected by aggregating
the log messages.
If alerting reasons are more explicitly presented in log messages.
For example, you want to receive alert notifications when more than 10 cases
are created in Salesforce within an hour. The sf-notifier scraping
endpoint does not expose such information. However, sf-notifier logs are
stored in OpenSearch and using prometheus-es-exporter you can perform the
following:
Configure a query using Query DSL (Domain Specific Language) and test it in
Dev Tools in in OpenSearch Dashboards.
Configure Prometheus Elasticsearch Exporter to expose the result as a
Prometheus metric showing the total amount of Salesforce cases created
daily, for example, salesforce_cases_daily_total_value.
Configure StackLight to send a notification once the value of this metric
increases by 10 or more within an hour.
Caution
StackLight logging must be enabled and functional.
Prometheus-es-exporter uses OpenSearch Search API. Therefore,
configured queries must be tuned for this specific API and must include:
The query part to filter documents
The aggregation part to combine filtered documents into a
metric-oriented result
In the manifest that opens, verify that StackLight logging is enabled:
logging:enabled:true
Create a query using Query DSL:
Select one of the following options:
Since Container Cloud 2.26.0 (Cluster releases 17.1.0 and
16.1.0)
In the OpenSearch Dashboards web UI, select an index to query.
StackLight stores logs in hourly OpenSearch indices.
Note
Optimize the query time by limiting the number of results.
For example, we will use the OpenSearch event.provider field
set to sf-notifier to limit the number of logs to search.
For example:
GET system/_search{"query":{"bool":{"filter":[{"term":{"event.provider":{"value":"sf-notifier"}}},{"range":{"@timestamp":{"gte":"now/d"}}}]}}}
Before Container Cloud 2.26.0 (Cluster releases 17.1.0 and
16.1.0)
In the OpenSearch Dashboards web UI, select an index to query.
StackLight stores logs in hourly OpenSearch indices. To select all
indices for a day, use the <logstash-{now/d}*> index pattern,
which stands for %3Clogstash-%7Bnow%2Fd%7D*%3E when URL-encoded.
Note
Optimize the query time by limiting the number of results.
For example, we will use the OpenSearch logger field set to
sf-notifier to limit the number of logs to search.
For example:
GET /%3Clogstash-%7Bnow%2Fd%7D*%3E/_search{"query":{"bool":{"must":{"term":{"logger":{"value":"sf-notifier"}}}}}}
Test the query in Dev Tools in OpenSearch Dashboards.
Select the log lines that include information about Salesforce cases
creation. For the info logging level, to indicate case creation,
sf-notifier produces log messages similar to the following one:
[2021-07-02 12:35:28,596] INFO in client: Created case: OrderedDict([('id', '5007h000007iqmKAAQ'), ('success', True), ('errors', [])]).
Such log messages include the Created case phrase. Use it in the query
to filter log messages for created cases:
Combine the query result to a single value that
prometheus-es-exporter will expose as a metric. Use the
value_count aggregation:
Since Container Cloud 2.26.0 (Cluster releases 17.1.0 and
16.1.0)
GET system/_search{"query":{"bool":{"filter":[{"term":{"event.provider":{"value":"sf-notifier"}}},{"range":{"@timestamp":{"gte":"now/d"}}},{"match_phrase_prefix":{"message":"Created case"}}]}},"aggs":{"daily_total":{"value_count":{"field":"event.provider"}}}}
Before Container Cloud 2.26.0 (Cluster releases 17.1.0 and
16.1.0)
GET /%3Clogstash-%7Bnow%2Fd%7D*%3E/_search{"query":{"bool":{"must":{"term":{"logger":{"value":"sf-notifier"}}},"filter":{"match_phrase_prefix":{"message":"Created case"}}}},"aggs":{"daily_total":{"value_count":{"field":"logger"}}}}
The aggregation result in Dev Tools should look as follows:
"aggregations":{"daily_total":{"value":19}}
Note
The metric name is suffixed with the aggregation name and
the result field name: salesforce_cases_daily_total_value.
In the example below, salesforce_cases is the query name. The final
metric name can be generalized using the
<query_name>_<aggregation_name>_<aggregation_result_field_name>
template.
Since Container Cloud 2.26.0 (Cluster releases 17.1.0 and
16.1.0)
prometheusServer:customAlerts:-alert:SalesforceCasesDailyWarningannotations:description:The number of cases created today in Salesforce increased by 10 within the last hour.summary:Too many cases in Salesforceexpr:increase(salesforce_cases_daily_total_value[1h]) >= 10labels:severity:warningservice:custom
For complex monitoring scenarios, you may need to extract specific information
from unstructured log messages and use it as metric labels. This is
particularly useful when log messages contain important identifiers or context
that is not available as structured fields.
Example: Extracting instance UUIDs from nova-compute warning logs¶
Consider a scenario where you want to monitor PCI slot warnings per instance
and host. The raw log messages contain instance UUIDs embedded in the text, but
these are not available as structured fields. For example:
2025-11-06 14:00:58.443 1 WARNING nova.compute.manager [None req-2647ed33-54be-4cbc-843e-ef2afbe1f393 18559bc87f394d8fbdcbc4aae5ca4565 5809824ec0524f7ea0c0a633eefcc372 - - default default] [instance: c15ed8f2-327f-49c1-8a6e-e6bbbb38f67d] attach interface failed , try to deallocate port 1038bf80-1002-438b-aa64-117124e36e79, reason: Instance c15ed8f2-327f-49c1-8a6e-e6bbbb38f67d has no free PCI slots available: nova.exception.NoPciSlots: Instance c15ed8f2-327f-49c1-8a6e-e6bbbb38f67d has no free PCI slots available
In this example, the query breakdown is as follows:
Query section
Description
Message content filtering
Uses multi_match with phrase matching to find log messages containing
has no free PCI slots available. This targets specific PCI slot error
messages.
Container filtering
Filters to only the nova-compute container logs using match_phrase
on the container.name field.
Log level filtering
Restricts results to warning level logs using match_phrase on the
log.level field.
Hostname validation
Ensures that the log has a valid host.hostname field using the
exists filter.
Time range filtering
Limits results to the last hour using the range filter on
@timestamp.
UUID extraction
Uses a Painless script with the regex pattern
\\[instance:([0-9a-f-]{36})\\] to extract instance UUIDs from log
messages such as [instance:c15ed8f2-327f-49c1-8a6e-e6bbbb38f67d].
Aggregation
Groups results by extracted instance UUID, then by hostname, creating
hierarchical metric labels for monitoring per instance and node.
The following configuration example for prometheus-es-exporter creates
metrics with labels for each instance UUID and hostname combination. This
allows you to monitor per-instance and per-node PCI slot warnings.