Example #1
0
    def send_to_telegraf(self):
        url = urlparse(self.config['address'])

        sock = BaseSocket(url)
        self.log.debug('Sending data to Telegraf at %s', sock.address)
        now = self.now()
        with sock as s:
            try:
                for measurement in self.gather_measurements():
                    self.log.debug(measurement)
                    line = Line(measurement['measurement'],
                                measurement['value'], measurement['tags'], now)
                    self.log.debug(line.to_line_protocol())
                    s.send(line.to_line_protocol())
            except (socket.error, RuntimeError, IOError, OSError):
                self.log.exception('Failed to send statistics to Telegraf:')
Example #2
0
    def send_to_telegraf(self):
        url = urlparse(self.config['address'])

        sock = BaseSocket(url)
        self.log.debug('Sending data to Telegraf at %s', sock.address)
        now = self.now()
        with sock as s:
            try:
                for measurement in self.gather_measurements():
                    self.log.debug(measurement)
                    line = Line(measurement['measurement'],
                                measurement['value'],
                                measurement['tags'], now)
                    self.log.debug(line.to_line_protocol())
                    s.send(line.to_line_protocol())
            except (socket.error, RuntimeError, IOError, OSError):
                self.log.exception('Failed to send statistics to Telegraf:')
Example #3
0
    def metric(self, measurement_name, values, tags=None, timestamp=None):
        """
        Append global tags configured for the client to the tags given then
        converts the data into InfluxDB Line protocol and sends to to socket
        """
        if not measurement_name or not values:
            # Don't try to send empty data
            return

        tags = tags or {}

        # Do a shallow merge of the metric tags and global tags
        all_tags = dict(self.tags, **tags)

        # Create a metric line from the input and then send it to socket
        line = Line(measurement_name, values, all_tags, timestamp)
        self.send(line.to_line_protocol())
Example #4
0
    def metric(self, measurement_name, values, tags=None, timestamp=None):
        """
        Append global tags configured for the client to the tags given then
        converts the data into InfluxDB Line protocol and sends to to socket
        """
        if not measurement_name or not values:
            # Don't try to send empty data
            return

        tags = tags or {}

        # Do a shallow merge of the metric tags and global tags
        all_tags = dict(self.tags, **tags)

        # Create a metric line from the input and then send it to socket
        line = Line(measurement_name, values, all_tags, timestamp)
        self.send(line.to_line_protocol())