示例#1
0
    cfg.StrOpt('doc_type', default='metrics',
               help='The doc type that metrics will be saved into.'),
    cfg.StrOpt('index_strategy', default='fixed',
               help='The index strategy used to create index name.'),
    cfg.StrOpt('index_prefix', default='data_',
               help='The index prefix where metrics were saved to.'),
    cfg.IntOpt('size', default=10000,
               help=('The query result limit. Any result set more than '
                     'the limit will be discarded. To see all the matching '
                     'result, narrow your search by using a small time '
                     'window or strong matching name')),
]

cfg.CONF.register_opts(METRICS_OPTS, group="metrics")

LOG = log.getLogger(__name__)


class ParamUtil(object):

    @staticmethod
    def _default_st():
        # default start time will be 30 days ago
        return tu.utcnow() - datetime.timedelta(30)

    @staticmethod
    def _default_et():
        # default end time will be current time
        return tu.utcnow()

    @staticmethod
示例#2
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import collections
import copy
import json
from kiloeyes.common import alarm_expr_calculator as calculator
from kiloeyes.common import alarm_expr_parser as parser
from kiloeyes.openstack.common import log
from kiloeyes.openstack.common import timeutils as tu
import uuid

LOG = log.getLogger(__name__)

reasons = {
    'ALARM': 'The alarm threshold(s) have '
    'been exceeded for the sub-alarms',
    'OK': 'The alarm threshold(s) have '
    'not been exceeded for the sub-alarms',
    'UNDETERMINED': 'Unable to determine the alarm state'
}


class ThresholdProcessor(object):
    """Thresh processor.

    This processor is for alarm definitions with short period.
    It will store the metrics value/timestamp in memory using dict.