mirror of
https://github.com/apache/druid.git
synced 2025-02-06 18:18:17 +00:00
* Adding licenses and enable apache-rat-plugi. Change-Id: I4685a2d9f1e147855dba69329b286f2d5bee3c18 * restore the copywrite of demo_table and add it to the list of allowed ones Change-Id: I2a9efde6f4b984bc1ac90483e90d98e71f818a14 * revirew comments Change-Id: I0256c930b7f9a5bb09b44b5e7a149e6ec48cb0ca * more fixup Change-Id: I1355e8a2549e76cd44487abec142be79bec59de2 * align Change-Id: I70bc47ecb577bdf6b91639dd91b6f5642aa6b02f
66 lines
1.9 KiB
Python
Executable File
66 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import argparse
|
|
import json
|
|
import random
|
|
import sys
|
|
from datetime import datetime
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Generate example page request latency metrics.')
|
|
parser.add_argument('--count', '-c', type=int, default=25, help='Number of events to generate (negative for unlimited)')
|
|
args = parser.parse_args()
|
|
|
|
count = 0
|
|
while args.count < 0 or count < args.count:
|
|
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
r = random.randint(1, 4)
|
|
if r == 1 or r == 2:
|
|
page = '/'
|
|
elif r == 3:
|
|
page = '/list'
|
|
else:
|
|
page = '/get/' + str(random.randint(1, 99))
|
|
|
|
server = 'www' + str(random.randint(1, 5)) + '.example.com'
|
|
|
|
latency = max(1, random.gauss(80, 40))
|
|
|
|
print(json.dumps({
|
|
'timestamp': timestamp,
|
|
'metricType': 'request/latency',
|
|
'value': int(latency),
|
|
|
|
# Additional dimensions
|
|
'page': page,
|
|
'server': server,
|
|
'http_method': 'GET',
|
|
'http_code': '200',
|
|
'unit': 'milliseconds'
|
|
}))
|
|
|
|
count += 1
|
|
|
|
try:
|
|
main()
|
|
except KeyboardInterrupt:
|
|
sys.exit(1)
|