Example #1
0
    def prometheus_query(self, line, cell):
        args = magic_arguments.parse_argstring(self.prometheus_query, line)
        result = query.Prometheus(args.url).query(cell, time=args.time, timeout=args.timeout)

        if args.output:
            self.shell.user_ns[args.output] = result
        else:
            return result
Example #2
0
    def prometheus_query_range(self, line, cell):
        args = magic_arguments.parse_argstring(self.prometheus_query_range, line)
        result = query.Prometheus(args.url).query_range(
            cell, args.start, args.end, args.step, timeout=args.timeout)

        if args.output:
            self.shell.user_ns[args.output] = result
        else:
            return result
Example #3
0
    def prometheus_query_range_now(self, line, cell):
        args = magic_arguments.parse_argstring(self.prometheus_query_range_now, line)
        duration = util.duration(args.duration) if isinstance(args.duration, str) else args.duration
        end = datetime.datetime.now(datetime.timezone.utc)
        start = end - datetime.timedelta(seconds=duration)
        result = query.Prometheus(args.url).query_range(
            cell, start, end, args.step, timeout=args.timeout)

        if args.output:
            self.shell.user_ns[args.output] = result
        else:
            return result