Ceilometr:12, Gnocchi2.0 source Analysis __ceilometer

Source: Internet
Author: User
Tags statsd

Gnocchi is a database used for multi-lease time Series aggregation processing. Can be used for time series aggregation, statistical processing.


1 Overview of the listing

Gnocchi the following mainly include etc directory, gnocchi directory, setup.cfg files, setup.py files.

In the gnocchi directory mainly includes: Aggregates directory, indexer directory, rest directory, storage directory,

__init__.py,arrchive_policy.py,carbonara.py,cli.py,opts.py,service.py,statsd.py.


2gnocchi Introduction to below non-directory files

__init__.py: Empty file

arrchive_policy.py: The main definition of the Low,medium.high default archiving policy, archiving policy (name, fallback window, definition, aggregation method list), archiving policy entries (granularity, number of points, time span)

carbonara.py: Contains Timeserie Class (Time series, essence is mapping, sortable, remove duplicate index), Boundtimeserie (Inherit Timeserie class, set metric size of each processing), Aggregatedtimeserie (inherited from Timeserie, which is important, contains the external incoming time series (mappings) of the update function, and the currently existing time series operations, as well as the _resample functions, grouped by sampling. and applying the aggregation method to the set of the point, generating the time series after the aggregation, timeseriearchive

cli.py: Important, contains the database generated entry method upgrade (), API entry Method API (), STATSD entry Method STATSD (),

The entry method of aggregation and Statistics METRICD (), important.

Metricprocessbase (the monitoring item handles the base class, initializes the database, then goes into the thread loop, executes the task
), Metricreporting (inherits from Metricprocessbase, The thread task performed is to print the sample quantity of the monitored items to be processed, metricprocessor (important class, inherit from Metricprocessbase, get the list of measured values from the queue and process, including aggregation, update, resampling, etc. important operations)


service.py: Provides a prepare_service function for registering configuration option groups, setting APIs and METRICD number of workers


statsd.py: Contains the stats class (gets the drive of the repository and index library, connects to the index library, retrieves the resource, traverses the measured value of the resource, invokes the measured value of the monitoring entry through the influxdbclient), Statsdserver Class (statistic service, The main connection receives the data each row parsing, obtains the monitor item name and the sampling value, sets the monitoring item corresponding measure value

), the Start () method opens the service, instantiates the stats object, creates a data point, invokes Asyncio, and permanently opens the service


opts.py: A list of configuration items that consist of indexer,metricd,api,storage tuples


genconfig.py: Generate configuration files mainly according to gnocchi-config-generator.conf gnocchi.conf

Aggregates directory: contains __init__.py and moving_stats.py

__init__.py:customaggregator (object): function: A custom collector, an abstract class that contains an abstract method: compute.

Moving_stats.py:MovingAverage (inherited from Customaggregator): contains: Aggregate_data and Compute methods


3 Rest Directory

Is that the API translates into gnocchi that can handle requests for the entry class, including many controller methods. Because Gnocchi uses pecan (object routing Web framework to obtain resources), the method provided by this file is to parse the URL passed over and execute the relevant commands after parsing the corresponding method.

__init__.py:

The more important methods include: Metriccontroller (inherited from rest.) Restcontroller

, provides post_measures to add an array of measurements, gets a list method of a monitor measure get_measures, and metricscontroller (the monitored item is given to Metriccontroller for the monitoring item ID resolution), Namedmetriccontroller (can be queried according to the monitor item name, according to the resource ID, type, monitor list to update resources), Metricsmeasuresbatchcontroller

(important, the monitoring of the measured value batch controller, in effect, is to traverse each monitoring item, add the sampling value list of each monitor item to the database). Other....

App.py:app.py is the portal for pecan applications, including application initialization code. Hooks the corresponding configuration is some pecan hooks, the role is similar to Wsgimiddleware

Gnocchihook class (provided before Pecan tries to distribute a request to a controller)

function On_route). The Load_app method (Paste.deploy is mainly used to load webapp in Wsgi, and its core function is Loadapp () to load Loadapp application via egg function and a configuration file or Wsgi packet

A profile suffix is ini and the content is divided into many segments): It is actually getting the Storage,indexer database drive and then deploying the build app and returning. Werkzeugapp Class (Incoming configuration file, splitting the GNOCCHI-API process, and avoiding the main process from creating a connection to the storage/indexer.)  Werkzeug is a WSGI toolkit that can serve as the underlying library for a web framework. ) 
Build_server (): Execute: Service.prepare_service (), execute: serving.run_simple
App.wsgi File: main call conf = Service.prepare_service (), application = App.load_app (conf)


4 Indexer Directory

__init__.py: Provides a get_driver (conf) method that returns the configured database drive object according to the Indexer.url in the configuration file to obtain the drive of the indexed database.

Indexerdriver classes (in fact, resources, archiving policies, archive policy rules, etc. are stored in the indexer
function: Abstract classes, encapsulating connections, disconnecting, upgrading functions, getting resources, getting resource listings)
Sqlalchemy_ base.py: This file mainly defines the tables in the Index library indexer. For example:
archivepolicy,metric and so on.
 sqlalchemy.py: Provide get_resource_mappers methods (may be important, do not know how resources are generated), Perinstancefacade class (including independent writing, read-write, read-connect, etc., get the database engine, etc.
), Sqlalchemyindexer (indexer. Indexerdriver): Stevedoe loading resource plug-ins, such as volume,instance, can be database migration, upgrade,
generate resource types to the mapping of the class, important (possibly add new resources to add here); include creating resources, listing/ Remove an interface sqlalchemy_extension.py such as an archive policy
: Important, the file includes some resource tables, such as Image,instance,volume, which may subsequently add new resources in this file. 


5 Storage Directory

Contains files such as __init__.py,_carbonara.py,ceph.py,file.py,influxdb.py,swift,py

The aggregate results of the final storage are in the storage database. So important.

__init__.py: Provides the Get_driver (conf) method to return the class of the drive based on the drive that stores the database in the configuration file; Storagedriver class Storage-driven database, including: initializing, stopping, processing rollback tasks, physical deletion, processing/ Get measurements and other features (but most of them are not implemented)

_carbonara.py:carbonarabasedstorage (important class, inherited from Storagedriver

, including adding a list of measures, processing measurements, obtaining measurements, removing monitoring items, and so on

There is an important method process_measures: Traverse every monitor, get each monitor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.