Viewing outgoing traffic usage

The bandwidth metric that can show outgoing traffic usage is not available by default. To be able to use it, you need to configure it first. A meter must be created for each new project. The meter only accounts traffic that goes through a virtual router. You cannot measure traffic going to or from ports directly attached to virtual machines.

Prerequisites

To measure outgoing traffic for a project

  1. Create a meter for a project. For example, to create the meter outgoing_traffic_project1 in the project project1 within the domain domain1, run:

    # openstack --insecure network meter create outgoing_traffic_project1 --project project1 --project-domain domain1
  2. Create a rule for the meter to account all traffic leaving the project router. For example:

    # openstack --insecure network meter rule create outgoing_traffic_project1 --egress --include \
    --remote-ip-prefix 0.0.0.0/0 --project project1 --project-domain domain1

    The new meter with the type bandwidth will be created and associated with the project project1 in the domain domain1.

  3. List all of the bandwidth metrics. For example:

    # gnocchi --insecure metric list | grep bandwidth
    +--------------------------------------+---------------------+-----------+------+--------------------------------------+
    | id                                   | archive_policy/name | name      | unit | resource_id                          |
    +--------------------------------------+---------------------+-----------+------+--------------------------------------+
    | a7982897-42c3-4586-bb4a-8c1b8d11fcc6 | low                 | bandwidth | B    | 883fb5e5-be97-4fbf-b1bd-8f33e552f214 |
    | ac2bf21d-f2b0-4043-9fb1-59e1930e497c | low                 | bandwidth | B    | 7147aba5-829e-49b7-a520-01b300178f6c |
    +--------------------------------------+---------------------+-----------+------+--------------------------------------+

    In this output, resource_id is the meter ID, so you can use it to identify meters.

    # openstack --insecure network meter list
    +--------------------------------------+---------------------------+-------------+--------+
    | ID                                   | Name                      | Description | Shared |
    +--------------------------------------+---------------------------+-------------+--------+
    | 883fb5e5-be97-4fbf-b1bd-8f33e552f214 | outgoing_traffic_project1 |             |        |
    | 7147aba5-829e-49b7-a520-01b300178f6c | outgoing_traffic_project2 |             |        |
    +--------------------------------------+---------------------------+-------------+--------+
    
  4. View the measures by using the metric id. For example:

    # gnocchi --insecure measures show a7982897-42c3-4586-bb4a-8c1b8d11fcc6 --aggregation sum
    +---------------------------+-------------+---------+
    | timestamp                 | granularity |   value |
    +---------------------------+-------------+---------+
    | 2021-10-03T02:40:00+03:00 |       300.0 |  1045.0 |
    | 2021-10-03T02:50:00+03:00 |       300.0 |  1907.0 |
    | 2021-10-03T02:55:00+03:00 |       300.0 | 15932.0 |
    +---------------------------+-------------+---------+

To exclude outgoing traffic for a network

Create a rule for the meter to exclude outgoing traffic for a particular network. For example, for the network with the CIDR 10.0.0.0/24, run:

# openstack --insecure network meter rule create outgoing_traffic --egress --exclude \
--remote-ip-prefix 10.0.0.0/24 --project project1 --project-domain domain1