summaryrefslogtreecommitdiff
path: root/tests/examplefiles/example.juttle
blob: ae8619960b585cf1ebe2efceb1fe5bee47f4c6c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Block comment */
/*
    Multiline block
    comment
*/

// inline comment
function juttleFunction(arg) {
    if (arg == null) {
        return null;
    }
    else if (arg == 0) {
        return 'zero';
    }
    else if (arg == 1) {
        return "one";
    }
    else {
        return 1.1;
    }
}

reducer juttleReducer(field) {
    var x = 0;
    function update() {
        x = *field;
    }

    function result() {
        return x;
    }
}

sub myemit(limit) {
    emit -limit limit
}

input test: text -default 'input';
const object = {
    xyz: 123,
    name: 'something'
};

const array = [
    :2016-01-01:,
    :2016-01-01T01:00:00:,
    :2016-01-01T01:00:00.000:,
    :2016-01-01T01:00:00.000Z:,
    :2016-01-01T01:00:00.000-0800:,
    :2016-01-01T01:00:00.000-08:00:,
    :00:00:01:,
    :00:00:00.001:,
    :now:,
    :beginning:,
    :end:,
    :forever:,
    :yesterday:,
    :today:,
    :tomorrow:,
    :1:,
    :1.1:,
    :1s:,
    :1 second:,
    :1 seconds:,
    :100ms:,
    :100 millisecond:,
    :100 milliseconds:,
    :1d:,
    :1 day:,
    :1 days:,
    :.2h:,
    :1.2h:,
    :.2 hour:,
    :1.2 hours:,
    :.5d:,
    :1.5d:,
    :.5 day:,
    :1.5 days:,
    :5m:,
    :5 minutes:,
    :10w:,
    :10 weeks:,
    :10M:,
    :10 months:,
    :100y:,
    :100 years:,
    :1 year and 2 months and 2 days:
];

emit
  | batch :10 minutes:
  | filter x=true
  | head 1
  | join
  | keep x
  | pace -every :1 minute:
  | pass
  | put y=false
  | remove z
  | sequence
  | skip 1
  | sort field -desc
  | split field
  | tail 10
  | unbatch
  | uniq field
;

read adapter -last :day: 'search' AND field~/pattern/ OR field == 'string'
  | write adapter