当前位置: 首页>>代码示例>>Python>>正文


Python InfluxDBClusterClient.get_list_series方法代码示例

本文整理汇总了Python中influxdb.InfluxDBClusterClient.get_list_series方法的典型用法代码示例。如果您正苦于以下问题:Python InfluxDBClusterClient.get_list_series方法的具体用法?Python InfluxDBClusterClient.get_list_series怎么用?Python InfluxDBClusterClient.get_list_series使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在influxdb.InfluxDBClusterClient的用法示例。


在下文中一共展示了InfluxDBClusterClient.get_list_series方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: InfluxDBWrapper

# 需要导入模块: from influxdb import InfluxDBClusterClient [as 别名]
# 或者: from influxdb.InfluxDBClusterClient import get_list_series [as 别名]
class InfluxDBWrapper(object):
    """ Wrapper the influxdb API, Return Data

    Args:
        __status__: the connection status
        __connection__: the connection object of the influxdb database
    """

    status = 0
    __connection__ = None

    def __init__(self, influxdb_hosts=[('101.201.235.144', 8086)], influxdb_user='root', influxdb_passwd='root', influxdb_database='k8s'):
        """Init the wrapper

        Args:
            influxdb_hosts: list of influxdb host tuple, like (ip_address, ip_port)
            influxdb_user: influxdb user 
            influxdb_passwd: influxdb password
            influxdb_database: influxdb database

        Description:
            If the function is compiled with docker, 
            Then we can set the influxdb address as SERVICE/PORT in Kubernetes
        """
       
        if len(influxdb_hosts) == 1:
            try:
                self.__connection__ = InfluxDBClient(influxdb_hosts[0][0], influxdb_hosts[0][1], influxdb_user, influxdb_passwd, influxdb_database)
            except:
                self.__status__ = 1
        else:
            try:
                self.__connection__ = InfluxDBClusterClient(influxdb_hosts, influxdb_user, influxdb_passwd, influxdb_database)
            except:
                self.__status__ = 1

    def show_tables(self):
        """ Influxdb SQL name table as measurement.
            
        Show tables would be necessary
        """

        return self.show_measurements();

    def show_measurements(self):
        """ The same functions as show_tables
        """ 

        sql_string = 'SHOW MEASUREMENTS'
        return self.query(sql_string)

    def list_series(self, json_str=True):
        """ Show the database series

        Args:
            json_str: the switch whether to open it with JSON
        """

        if json_str == True:
            return json.dumps(self.__connection__.get_list_series(database))

    def show_tag_keys(self, measurements='cpu/node_reservation'):
        """ Show the measurements tag keys

        Args:
            measurements: the target measurements
        """

        sql_string = "SHOW TAG KEYS FROM \"" + measurements + "\""
        return self.query(sql_string)

    def show_field_keys(self, measurements='cpu/node_reservation'):
        """ Show the measurements field

        Args:
            measurements: the target measurements
        """

        sql_string = "SHOW FIELD KEYS FROM \"" + measurements + "\""
        return self.query(sql_string)

    def last_records(self, measurements='cpu/usage'):
        """ Get the lastest record 

        Args:
            measurements: the target measurements
        """ 

        sql_string = "SELECT * FROM \"" + measurements + "\" WHERE time > now() - 1h ORDER BY time DESC LIMIT 20 "
        return self.query(sql_string)

    def period_records(self, measurements='cpu/usage_rate', group_by='nodename', time_durations='1h'):
        """ Show the node cpu usage

        Args:
            measurements: the target measurements
            group_by: the group by object
            time_duration: time duration from now
        """

#.........这里部分代码省略.........
开发者ID:rainlight,项目名称:ansible.conf,代码行数:103,代码来源:influxdb_api.py


注:本文中的influxdb.InfluxDBClusterClient.get_list_series方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。