Li Yuanjun is a Web and cloud computing developer. Java, Python, Golang enthusiast.

Personal website: Tomoncle.com

The author of this article has joined the Python Chinese Community Columnist Program.

Prometheus is an open source monitoring system derived from Google Borgmon and developed in Golang. Many are calling it the next generation of surveillance systems. Prometheus is responsible for capturing the status of monitored components periodically through HTTP, allowing any component to access the monitoring system through HTTP without any SDK (note: Prometheus uses UTC UTC for data logging).

FAQ

Why write this article?

As we’ve been doing cloud work for a few years now, we’ve been monitoring business scenarios, and rometheus is the open source tool that we use as a monitoring tool. Of course, Prometheus is a mature ecosystem, but for certain scenarios like taking virtual machines or containers online or offline, We usually view these in the PaaS container list or IaaS virtual machine list. Its native UI can not meet our needs, so we need to query through Http interface. For example, if we do not display grafana, but customize our OWN UI monitoring page, HTTP interface queries must be implemented, which is why I wanted to write this article.

Prometheus about?

We won’t say much about Prometheus here, because the official documentation (Prometheus.io /) is a better choice when…

prometheus-http-client

When I was doing cloud monitoring, due to time constraints and heavy tasks, and the monitoring engine of our company at that time had already used Java to write part of it, I directly developed it on the original basis. However, at the end, there were more demands and I felt more and more trouble, because Java realized a simple HTTP query. I had to convert json (which was a bit more complicated than Python), implement the corresponding HTTP query interface, etc., so I implemented Prometheus HTTP API based on Python in my spare time. Support Prometheus, node_exporter, mysqLD_exporter, Memcached_exporter, and other client queries via Python decorator. If you are not interested in monitoring, you can also browse the use of decorators in this project. The official document: tomoncle. Making. IO/Prometheus -…

The environment

  • Prometheus installation:
Wget $$at https://github.com/prometheus/prometheus/releases/download/v2.8.0-rc.0/prometheus-2.8.0-rc.0.linux-amd64.tar.gz The tar ZXVF Prometheus - 2.8.0 - rc. 0. Linux - amd64. Tar. GzCopy the code
  • Default configuration (see the official documents for other component configurations. If other components are installed, you can query the corresponding client):
global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: 'codelab-monitor' # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: Periodically Load rules once and evaluate them according to the global 'evaluation_interval'. rule_files: # - "first.rules" # - "second.rules" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090']Copy the code

A simpler extension: Use a wrapper to automatically select the query mode without any implementation. (See “Core Implementation” below for principles and implementation)

@prom
def go_gc_duration_seconds(self, **kwargs):
    pass

@prom
def go_gc_duration_seconds_count(self, **kwargs):
    pass
Copy the code

Custom query expressions: No implementation is required. (See “Core Implementation” below for principles and implementation)

@relabel('100 - (avg by (instance, job) (irate(node_cpu{mode="idle"}[5m])) * 100)')
def node_cpu_rate(self, **kwargs):
      pass

@relabel(
      '(node_filesystem_size{} - node_filesystem_free{})'
      ' / (node_filesystem_size{} - node_filesystem_free{} + node_filesystem_avail{})'
      ' * 100')
def node_disk_rate(self, **kwargs):
    pass
Copy the code

Rich query selector: support multi-label query.

  • Parameters:

    • graph: True/False, default False
    • start: timestamp, if graph is True, must be supplied
    • end: timestamp, if graph is True, must be supplied
    • step: int (step spacing), defaults to None
    • time: timestamp, default time.time()
    • filter: {‘instance’:’127.0.0.1′, ‘label’:’go lang’,… }, defaults to None
  • Return JSON data:

Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> from prometheus_http_client import NodeExporter >>> node_exporter =  NodeExporter() >>> node_exporter.node_cpu_rate(filter={'instance': '127.0.0.1:9100', 'mode' : 'user', 'job' : 'static_nodes}) U '{" status ":" success ", "data" : {" resultType ":" vector ", "result" : [{" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes "}, "value" : [1533779495.799, "70.7333333333338"]}]}} "> > > > > > node_exporter. Node_cpu_rate (filter = {' instance: '127.0.0.1:9100', 'job' : 'static_nodes}) U '{" status ":" success ", "data" : {" resultType ":" vector ", "result" : [{" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes "}, "value" : [1533779522.109, "2.2500000000051443"]}]}} "> > >Copy the code

The installation

  • Install from source code:
$ git clone https://github.com/tomoncle/prometheus-http-client.git
$ cd prometheus-http-client && sudo python setup.py install
Copy the code
  • PIP installation:
$ pip install prometheus-http-client
Copy the code

configuration

Default: http://localhost:9090 Updated: $export PROMETHEUS_URL='http://192.168.1.2:9090' $ export PROMETHEUS_HEAD='{"Cookie": "123456"}'Copy the code

expand

expand

Refer to other exporters in the catalog and inherit the “exporter” class without any implementations

\

  • Example:

Core implementation (Python decorator)

  • PROM: Use this decorator to automatically parse function names, and automatically build query expressions based on function names, make HTTP requests, and return JSON data
def prom(func): """ execute metric request :param func: exporter method :return: metric monitor data, json """ def wrapper(*args, **kwargs): graph = kwargs.pop('graph', False) filters = kwargs.pop('filter', {}) prometheus = Prometheus() kwargs['metric'] = func.__name__ + _build_params(filters) function = prometheus.query_rang  if graph else prometheus.query try: _ignore(args) return function(**kwargs) except AssertionError: raise except Exception as e: raise PrometheusError(e) return wrapperCopy the code
  • Relabel: This decorator displays expressions specified with relabel parameter values. This is a flexible implementation based on PROM decorators that allows users to customize complex expressions
def relabel(name):
    """
    rename metric name
    :param name:
    :return: metric monitor data, json
    """

    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            func.__name__ = name
            filters = kwargs.pop('filter', {})
            if '{mode="idle"}' in name and 'mode' not in filters.keys():
                filters['mode'] = 'idle'
            query = _build_params(filters)
            if query:
                func.__name__ = name.replace('{mode="idle"}', query).replace('{}', query)
            return prom(func)(*args, **kwargs)

        return wrapper

    return decorator
Copy the code
  • Check_params: checks function parameter values
def check_params(params) :
    def decorator(func) :
        def wrapper(*args, **kwargs) :
            if isinstance(params, str) :if not kwargs.get(params, None) :raise AssertionError('parameter "{}" is necessary.'.format(params))
            elif isinstance(params, list) :for param in params:
                    if not kwargs.get(param, None) :raise AssertionError('parameter "{}" is necessary.'.format(params))
            else:
                raise AssertionError('parameter "{}" is necessary.'.format(params))
            return func(*args, **kwargs)

        return wrapper

    return decorator
Copy the code

Query Example

  • Prometheus client

    Python 2.76. (default, Jun 22 2015.17:58:13) 
    [GCC 4.82.] on linux2
    Type "help"."copyright"."credits" or "license" for more information.
    >>> 
    >>> from prometheus_http_client import Prometheus
    >>> prometheus = Prometheus()
    >>> prometheus.query(metric='irate(node_cpu{job="static_nodes"}[5m])')
    u'{"status":"success","data":{"resultType":"vector","result":[{"metric":{"cpu":"cpu0","device_ID":"static_node","instanc E ":" 127.0.0.1:9100 ", "job" : "static_nodes", "mode" : "idle"}, "value" : 1533779660.16, "0.9340000000001358"}, {" metric ": {" CPU" :" Cpu0, "" device_ID static_node" : ""," instance ":" 127.0.0.1:9100 ", "job" : "static_nodes", "mode" : "iowait"}, "value" : [1533779660.16 , "0.003333333333334091"]}, {" metric ": {" CPU" : "cpu0", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_no Des ", "mode" : "irq"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu0", "device_ID" : "static_node", "instance" : "127.0.0.1: 9100 ", "job" : "static_nodes", "mode" : "nice"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu0", "device_ID" : "static_node" , "instance", "127.0.0.1:9100", "job" : "static_nodes", "mode" : "softirq}", "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu0." , "device_ID", "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "steal"}, "value" : [1533779660.16, "0"]} {" metric ": {" CPU" : "cpu0", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "the system"}, "va Lue ": 1533779660.16," 0.016666666666666666 "}, {" metric ": {" CPU" : "cpu0", "device_ID" : "static_node", "instance" : "127.0.0.1:910 0 ", "job", "static_nodes", "mode" : "user"}, "value" : 1533779660.16, "0.025333333333340608"}, {" metric ": {" CPU" : "cpu1", "device_I D ":" static_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "idle"}, "value" : [1533779660.16, 0.9373333333333. 297 "]}, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "iowait "}, "value" : 1533779660.16, "0.025333333333333503"}, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_node", "instance" : "127.0.0 . "100", "job" : "static_nodes", "mode" : "irq"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_nod E ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "nice"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu1", "Device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "softirq}", "value" : [1533779660.16, "0"] }, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "steal"}, "va Lue ": 1533779660.16," 0 "}, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_no Des mode ":" ", "system"}, "value" : 1533779660.16, "0.0073333333333304536"}, {" metric ": {" CPU" : "cpu1", "device_ID" : "static_node" , "instance", "127.0.0.1:9100", "job" : "static_nodes", "mode" : "user"}, "value" : 1533779660.16, "0.02333333333332727"}, {" metric Cpu2 ": {" CPU" : ""," device_ID ":" static_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "idle"}, "value" : [15337 79660.16, the "0.9486666666666679"]}, {" metric ": {" CPU" : "cpu2", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "the sta Tic_nodes mode ":" ", "iowait"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu2", "device_ID" : "static_node", "instance" : "1 27.0.0.1:9100 ", "job" : "static_nodes", "mode" : "irq"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu2", "device_ID" : "stat Ic_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "nice"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" :" Cpu2, "" device_ID static_node" : ""," instance ":" 127.0.0.1:9100 ", "job" : "static_nodes", "mode" : "softirq"}, "value" : [1533779660.1 6, "0"]}, {" metric ": {" CPU" : "cpu2", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "steal "}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu2", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "the sta Tic_nodes mode ":" ", "system"}, "value" : 1533779660.16, "0.009333333333332423"}, {" metric ": {" CPU" : "cpu2", "device_ID" : "static_ Node "and" instance ":" 127.0.0.1:9100 ", "job" : "static_nodes", "mode" : "user"}, "value" : 1533779660.16, "0.0319999999999709"}, {" me Tric ": {" CPU" : "cpu3", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "idle"}, "value" : [1 533779660.16, the "0.9540000000000267"]}, {" metric ": {" CPU" : "cpu3", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "Static_nodes", "mode" : "iowait}", "value" : 1533779660.16, "0.0006666666666670077"}, {" metric ": {" CPU" : "cpu3", "device_ID" : "st Atic_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "irq"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "Cpu3", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "nice"}, "value" : [1533779660.16, "0"]}, {" metric ": {" CPU" : "cpu3", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "softirq "}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu3", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "the sta Tic_nodes mode ":" ", "steal"}, "value" : 1533779660.16, "0"}, {" metric ": {" CPU" : "cpu3", "device_ID" : "static_node", "instance" : "12 7.0.0.1:9100 ", "job" : "static_nodes", "mode" : "the system"}, "value" : 1533779660.16, "0.008666666666666363"}, {" metric ": {" CPU" : "cp U3, "" device_ID static_node" : ""," instance ":" 127.0.0.1:9100 ", "job" : "static_nodes", "mode" : "user"}, "value" : [1533779660.16, "0. 03266666666665211 "]}]}} '
    >>> 
    >>> prometheus.query(metric='sum by (mode, instance,job) (irate(node_cpu{job="static_nodes"}[5m]))')
    U '{" status ":" success ", "data" : {" resultType ":" vector ", "result" : [{" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes ", "mode", "system"}, "value" : 1533779830.339, "0.038000000000010914"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "the static _nodes mode ":" ", "user"}, "value" : 1533779830.339, "0.09133333333332606"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "the sta Tic_nodes mode ":" ", "idle"}, "value" : 1533779830.339, "3.8"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes", "m The ode ":" iowait "}, "value" : 1533779830.339, "0.035333333333332696"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nod Es ", "mode" : "irq"}, "value" : 1533779830.339, "0"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "nice "}, "value" : 1533779830.339, "0"}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "softirq}", "value" : [ 1533779830.339, the "0.0006666666666666524"]}, {" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes", "mode" : "steal"}, "va Lue ": [1533779830.339," 0 "]}]}} '
    >>> 
    Copy the code
  • The public Exporter (Promethew.io /) label

    • code :

      from prometheus_http_client import Exporter
      
      print(Exporter().go_gc_duration_seconds())
      Copy the code
    • data :

      {"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"go_gc_duration_seconds","device_ID":" Static_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "quantile" : "0"}, "value" : 1533734495.25, "0.00002624"}, {" me Tric ": {" __name__" : "go_gc_duration_seconds", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "q Uantile ":" 0.25 "}, "value" : 1533734495.25, "0.000048674"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "device_ID" : "stat Ic_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "quantile" : "0.5"}, "value" : 1533734495.25, "0.000064599"}, {" met Ric ": {" __name__" : "go_gc_duration_seconds", "device_ID" : "static_node", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "qu Antile ":" 0.75 "}, "value" : 1533734495.25, "0.000084196"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "device_ID" : "stati C_node ", "instance" : "127.0.0.1:9100", "job" : "static_nodes", "quantile" : "1"}, "value" : 1533734495.25, "0.002391278"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9104", "job" : "mysql", "mysql_version" : "5.7", "quantile" : "0"}," Value ": 1533734495.25," 0.000028267 "}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9104", "job" :" Mysql mysql_version ", "" :" 5.7 ", "quantile" : "0.25"}, "value" : 1533734495.25, "0.000040906"}, {" metric ": {" __name__" : "go_gc_dura Tion_seconds ", "instance" : "127.0.0.1:9104", "job" : "mysql", "mysql_version" : "5.7", "quantile" : "0.5"}, "value" : [1533734495.25." 0.00005304 "]}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9104", "job" : "mysql", "mysql_version" :" 5.7 ", "quantile" : "0.75"}, "value" : 1533734495.25, "0.000093971"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9104", "job" : "mysql", "mysql_version" : "5.7", "quantile" : "1"}, "value" : 1533734495.25, "0.004254732"}, {" metric ": { "__name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9107", "job" : "consul," "mysql_version" : "5.7", "quantile" : "0"}, "va Lue ": 1533734495.25," 0.00006202700000000001 "}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9107 ", "job" : "consul," "mysql_version" : "5.7", "quantile" : "0.25"}, "value" : 1533734495.25, "0.000198266"}, {" metric ": {" __name__" :" Go_gc_duration_seconds ", "instance" : "127.0.0.1:9107", "job" : "consul," "mysql_version" : "5.7", "quantile" : "0.5"}, "value" : [1533 734495.25, the "0.00020824000000000003"]}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9107", "job" : "c Onsul mysql_version ", "" :" 5.7 ", "quantile" : "0.75"}, "value" : 1533734495.25, "0.000271729"}, {" metric ": {" __name__" : "go_gc_dura Tion_seconds ", "instance" : "127.0.0.1:9107", "job" : "consul," "mysql_version" : "5.7", "quantile" : "1"}, "value" : [1533734495.25, "0 . 001790822 "]}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_versio N ":" 5.7 ", "quantile" : "0"}, "value" : 1533734495.25, "0.000025387"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "the instance ":" 127.0.0.1:9150 ", "job" : "memcached", "mysql_version" : "5.7", "quantile" : "0.25"}, "value" : 1533734495.25, "0.000037497"}, {" m Etric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "quantil E ":" 0.5 "}, "value" : 1533734495.25, "0.000060197"}, {" metric ": {" __name__" : "go_gc_duration_seconds", "instance" : "127.0.0.1:91 50 ", "job" : "memcached", "mysql_version" : "5.7", "quantile" : "0.75"}, "value" : 1533734495.25, "0.000111523"}, {" metric ": {" __name __ go_gc_duration_seconds ":" ", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "quantile" : "1"}, "value" : [1533734495.25, "0.000544621"]}]}}Copy the code
  • node_exporter

    • code :

      from prometheus_http_client import NodeExporter node_exporter = NodeExporter() # print(node_exporter.node_uname_info()) Print (node_exporter. Node_cpu_rate (filter = {' instance ':' 127.0.0.1:9100}))Copy the code
    • data :

      {" status ":" success ", "data" : {" resultType ":" vector ", "result" : [{" metric ": {" instance" : "127.0.0.1:9100", "job" : "static_nodes}" , "value" :] [1533734848.099, "11.816666666676014"]}}}Copy the code
  • mysqld_exporter

    • code :

      from prometheus_http_client import MysqlExporter
      
      print(MysqlExporter().mysql_exporter_scrapes_total())
      Copy the code
    • data :

      {"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"mysql_exporter_scrapes_total","instan Ce ":" 127.0.0.1:9104 ", "job" : "mysql", "mysql_version" : ""}," value ": 5.7 [1533735043.46," 345 "]}}}]Copy the code
  • consul_exporter

    • code :

      from prometheus_http_client import ConsulExporter
      print(ConsulExporter().consul_catalog_services())
      Copy the code
    • data :

      {"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"consul_catalog_services","instance":" 127.0.0.1:9107 ", "job" : "consul," "mysql_version" : ""}," value ": 5.7 [1533735232.039," 1 "]}]}}Copy the code
  • memcached_exporter

    • code :

      from prometheus_http_client import MemcachedExporter
      
      print(MemcachedExporter().memcached_commands_total())
      Copy the code
    • data :

      {"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"memcached_commands_total","command":" Cas, "" instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "badval"}, "value" : [1533735286.809, "0"] }, {" metric ": {" __name__" : "memcached_commands_total", "command" : "cas", "instance" : "127.0.0.1:9150", "job" : "memcached", "the mysql_ Version ":" 5.7 ", "status" : "hit"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "Cas," "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "miss"}, "value" : [1533735286.809, "0"]} {" metric ": {" __name__" : "memcached_commands_total", "command" : "decr", "instance" : "127.0.0.1:9150", "job" : "memcached", "the mysql_ Version ":" 5.7 ", "status" : "hit"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "Decr" and "instance", "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "miss"}, "value" : [1533735286.809, "0"] }, {" metric ": {" __name__" : "memcached_commands_total", "command" : "delete", "instance" : "127.0.0.1:9150", "job" : "memcached", "mys Ql_version ":" 5.7 ", "status" : "hit"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "comman D ", "delete", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "miss"}, "value" : [1533735286.809 , "0"]}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "flush", "instance" : "127.0.0.1:9150", "job" : "memcached". "Mysql_version" : "5.7", "status" : "hit"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "co Mmand ":" get ", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "hit"}, "value" : [1533735286.809 , "0"]}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "get", "instance" : "127.0.0.1:9150", "job" : "memcached", "m Ysql_version ":" 5.7 ", "status" : "miss"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "com Mand incr ":" ", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "hit"}, "value" : [1533735286.809 , "0"]}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "incr", "instance" : "127.0.0.1:9150", "job" : "memcached"," Mysql_version ":" 5.7 ", "status" : "miss"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "co Mmand ":" set ", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "hit"}, "value" : [1533735286.809 , "0"]}, {" metric ": {" __name__" : "memcached_commands_total", "command" : "touch", "instance" : "127.0.0.1:9150", "job" : "memcached". "Mysql_version" : "5.7", "status" : "hit"}, "value" : 1533735286.809, "0"}, {" metric ": {" __name__" : "memcached_commands_total", "co Mmand ":" touch ", "instance" : "127.0.0.1:9150", "job" : "memcached", "mysql_version" : "5.7", "status" : "miss"}, "value" : [1533735286. 809, "0"]]}}}Copy the code

See for more usage:Github.com/tomoncle/pr…Of course, if you have time, I hope you can help me to make this project better.

zhi

the

chi

a

zuo

As a

zhe

those

\

\

Long click scan code to encourage author \

The author of this article has joined the Python Chinese Community Columnist Program

\

Use Python to develop a timer program to generate tiktok character video with Python! The Python library is used to read and write the MySQL database

Click below to read the original article

Free to become a community registered member, members can enjoy more rights and interests