Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Pycti: Inconsistent Metrics Increment in Bundle Sending Process #934

@vince-isec

Description

@vince-isec

Description

The bundle_send metric is not incremented when using the API queue protocol in the send_stix2_bundle method of the OpenCTIConnectorHelper class. This leads to inaccurate metrics reporting, as the bundle_send_total counter remains at 0 even when bundles are successfully sent through the API protocol.

Environment

  1. Cloud Instance
  2. OpenCTI version: 6.7.3
  3. Other environment details: - CONNECTOR_QUEUE_PROTOCOL=api # Use api to send bundle through HTTP query to the API, amqp (default) to send to rabbit

Reproducible Steps

Current Behavior

In the send_stix2_bundle method of opencti_connector_helper.py, there are two different code paths based on the queue protocol:

  1. When using the AMQP protocol (self.queue_protocol == "amqp"), bundles are sent via the _send_bundle method, which correctly increments the bundle_send metric:

    self.metric.inc("bundle_send")
  2. When using the API protocol (self.queue_protocol == "api"), bundles are sent via the send_bundle_to_api method, but the metric is not incremented:

    elif self.queue_protocol == "api":
        self.api.send_bundle_to_api(
            connector_id=self.connector_id, bundle=bundle
        )
        # Missing: self.metric.inc("bundle_send")

Expected behaviour

The bundle_send metric should be incremented regardless of the queue protocol used, ensuring consistent and accurate metrics reporting.

Proposed Fix

Add the metric increment after the API call in the API protocol branch:

elif self.queue_protocol == "api":
    self.api.send_bundle_to_api(
        connector_id=self.connector_id, bundle=bundle
    )
    self.metric.inc("bundle_send")  # Add this line

Additional information

Affected Files

  • pycti/connector/opencti_connector_helper.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    buguse for describing something not working as expectedsolveduse to identify issue that has been solved (must be linked to the solving PR)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions