Add new line protocol parser and serializer, influxdb output (#3924)
This commit is contained in:
@@ -1,500 +0,0 @@
|
||||
ctr,host=tars,some=tag-0 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-1 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-2 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-3 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-4 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-5 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-6 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-7 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-8 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-9 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-10 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-11 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-12 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-13 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-14 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-15 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-16 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-17 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-18 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-19 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-20 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-21 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-22 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-23 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-24 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-25 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-26 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-27 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-28 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-29 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-30 n=3i 1476437629342569532
|
||||
ctr,host=tars,some=tag-31 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-32 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-33 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-34 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-35 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-36 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-37 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-38 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-39 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-40 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-41 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-42 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-43 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-44 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-45 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-46 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-47 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-48 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-49 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-50 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-51 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-52 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-53 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-54 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-55 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-56 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-57 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-58 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-59 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-60 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-61 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-62 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-63 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-64 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-65 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-66 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-67 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-68 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-69 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-70 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-71 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-72 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-73 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-74 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-75 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-76 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-77 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-78 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-79 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-80 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-81 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-82 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-83 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-84 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-85 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-86 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-87 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-88 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-89 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-90 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-91 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-92 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-93 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-94 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-95 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-96 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-97 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-98 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-99 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-100 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-101 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-102 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-103 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-104 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-105 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-106 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-107 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-108 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-109 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-110 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-111 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-112 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-113 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-114 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-115 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-116 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-117 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-118 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-119 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-120 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-121 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-122 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-123 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-124 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-125 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-126 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-127 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-128 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-129 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-130 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-131 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-132 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-133 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-134 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-135 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-136 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-137 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-138 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-139 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-140 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-141 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-142 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-143 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-144 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-145 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-146 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-147 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-148 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-149 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-150 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-151 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-152 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-153 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-154 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-155 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-156 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-157 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-158 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-159 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-160 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-161 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-162 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-163 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-164 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-165 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-166 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-167 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-168 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-169 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-170 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-171 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-172 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-173 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-174 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-175 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-176 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-177 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-178 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-179 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-180 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-181 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-182 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-183 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-184 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-185 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-186 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-187 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-188 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-189 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-190 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-191 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-192 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-193 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-194 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-195 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-196 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-197 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-198 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-199 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-200 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-201 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-202 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-203 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-204 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-205 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-206 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-207 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-208 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-209 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-210 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-211 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-212 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-213 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-214 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-215 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-216 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-217 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-218 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-219 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-220 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-221 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-222 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-223 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-224 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-225 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-226 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-227 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-228 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-229 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-230 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-231 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-232 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-233 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-234 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-235 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-236 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-237 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-238 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-239 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-240 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-241 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-242 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-243 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-244 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-245 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-246 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-247 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-248 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-249 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-250 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-251 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-252 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-253 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-254 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-255 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-256 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-257 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-258 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-259 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-260 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-261 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-262 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-263 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-264 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-265 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-266 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-267 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-268 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-269 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-270 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-271 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-272 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-273 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-274 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-275 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-276 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-277 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-278 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-279 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-280 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-281 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-282 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-283 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-284 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-285 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-286 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-287 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-288 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-289 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-290 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-291 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-292 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-293 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-294 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-295 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-296 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-297 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-298 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-299 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-300 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-301 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-302 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-303 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-304 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-305 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-306 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-307 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-308 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-309 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-310 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-311 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-312 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-313 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-314 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-315 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-316 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-317 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-318 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-319 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-320 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-321 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-322 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-323 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-324 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-325 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-326 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-327 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-328 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-329 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-330 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-331 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-332 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-333 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-334 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-335 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-336 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-337 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-338 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-339 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-340 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-341 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-342 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-343 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-344 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-345 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-346 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-347 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-348 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-349 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-350 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-351 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-352 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-353 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-354 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-355 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-356 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-357 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-358 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-359 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-360 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-361 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-362 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-363 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-364 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-365 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-366 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-367 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-368 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-369 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-370 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-371 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-372 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-373 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-374 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-375 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-376 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-377 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-378 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-379 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-380 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-381 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-382 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-383 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-384 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-385 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-386 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-387 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-388 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-389 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-390 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-391 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-392 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-393 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-394 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-395 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-396 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-397 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-398 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-399 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-400 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-401 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-402 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-403 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-404 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-405 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-406 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-407 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-408 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-409 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-410 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-411 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-412 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-413 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-414 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-415 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-416 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-417 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-418 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-419 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-420 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-421 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-422 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-423 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-424 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-425 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-426 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-427 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-428 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-429 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-430 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-431 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-432 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-433 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-434 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-435 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-436 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-437 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-438 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-439 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-440 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-441 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-442 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-443 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-444 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-445 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-446 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-447 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-448 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-449 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-450 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-451 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-452 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-453 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-454 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-455 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-456 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-457 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-458 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-459 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-460 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-461 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-462 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-463 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-464 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-465 n=0i 1476437629342523514
|
||||
ctr,host=tars,some=tag-466 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-467 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-468 n=0i 1476437629342569532
|
||||
ctr,host=tars,some=tag-469 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-470 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-471 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-472 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-473 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-474 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-475 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-476 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-477 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-478 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-479 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-480 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-481 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-482 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-483 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-484 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-485 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-486 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-487 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-488 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-489 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-490 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-491 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-492 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-493 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-494 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-495 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-496 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-497 n=2i 1476437629342569532
|
||||
ctr,host=tars,some=tag-498 n=1i 1476437629342569532
|
||||
ctr,host=tars,some=tag-499 n=1i 1476437629342569532
|
||||
89
plugins/parsers/influx/escape.go
Normal file
89
plugins/parsers/influx/escape.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package influx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
escapes = " ,="
|
||||
nameEscapes = " ,"
|
||||
stringFieldEscapes = `\"`
|
||||
)
|
||||
|
||||
var (
|
||||
unescaper = strings.NewReplacer(
|
||||
`\,`, `,`,
|
||||
`\"`, `"`, // ???
|
||||
`\ `, ` `,
|
||||
`\=`, `=`,
|
||||
)
|
||||
|
||||
nameUnescaper = strings.NewReplacer(
|
||||
`\,`, `,`,
|
||||
`\ `, ` `,
|
||||
)
|
||||
|
||||
stringFieldUnescaper = strings.NewReplacer(
|
||||
`\"`, `"`,
|
||||
`\\`, `\`,
|
||||
)
|
||||
)
|
||||
|
||||
func unescape(b []byte) string {
|
||||
if bytes.ContainsAny(b, escapes) {
|
||||
return unescaper.Replace(unsafeBytesToString(b))
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func nameUnescape(b []byte) string {
|
||||
if bytes.ContainsAny(b, nameEscapes) {
|
||||
return nameUnescaper.Replace(unsafeBytesToString(b))
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func stringFieldUnescape(b []byte) string {
|
||||
if bytes.ContainsAny(b, stringFieldEscapes) {
|
||||
return stringFieldUnescaper.Replace(unsafeBytesToString(b))
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
// parseIntBytes is a zero-alloc wrapper around strconv.ParseInt.
|
||||
func parseIntBytes(b []byte, base int, bitSize int) (i int64, err error) {
|
||||
s := unsafeBytesToString(b)
|
||||
return strconv.ParseInt(s, base, bitSize)
|
||||
}
|
||||
|
||||
// parseFloatBytes is a zero-alloc wrapper around strconv.ParseFloat.
|
||||
func parseFloatBytes(b []byte, bitSize int) (float64, error) {
|
||||
s := unsafeBytesToString(b)
|
||||
return strconv.ParseFloat(s, bitSize)
|
||||
}
|
||||
|
||||
// parseBoolBytes is a zero-alloc wrapper around strconv.ParseBool.
|
||||
func parseBoolBytes(b []byte) (bool, error) {
|
||||
return strconv.ParseBool(unsafeBytesToString(b))
|
||||
}
|
||||
|
||||
// unsafeBytesToString converts a []byte to a string without a heap allocation.
|
||||
//
|
||||
// It is unsafe, and is intended to prepare input to short-lived functions
|
||||
// that require strings.
|
||||
func unsafeBytesToString(in []byte) string {
|
||||
src := *(*reflect.SliceHeader)(unsafe.Pointer(&in))
|
||||
dst := reflect.StringHeader{
|
||||
Data: src.Data,
|
||||
Len: src.Len,
|
||||
}
|
||||
s := *(*string)(unsafe.Pointer(&dst))
|
||||
return s
|
||||
}
|
||||
95
plugins/parsers/influx/handler.go
Normal file
95
plugins/parsers/influx/handler.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package influx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
"github.com/prometheus/common/log"
|
||||
)
|
||||
|
||||
type MetricHandler struct {
|
||||
builder *metric.Builder
|
||||
metrics []telegraf.Metric
|
||||
precision time.Duration
|
||||
}
|
||||
|
||||
func NewMetricHandler() *MetricHandler {
|
||||
return &MetricHandler{
|
||||
builder: metric.NewBuilder(),
|
||||
precision: time.Nanosecond,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *MetricHandler) SetTimeFunc(f metric.TimeFunc) {
|
||||
h.builder.TimeFunc = f
|
||||
}
|
||||
|
||||
func (h *MetricHandler) SetPrecision(factor time.Duration) {
|
||||
h.precision = factor
|
||||
}
|
||||
|
||||
func (h *MetricHandler) Metric() (telegraf.Metric, error) {
|
||||
return h.builder.Metric()
|
||||
}
|
||||
|
||||
func (h *MetricHandler) SetMeasurement(name []byte) {
|
||||
h.builder.SetName(nameUnescape(name))
|
||||
}
|
||||
|
||||
func (h *MetricHandler) AddTag(key []byte, value []byte) {
|
||||
tk := unescape(key)
|
||||
tv := unescape(value)
|
||||
h.builder.AddTag(tk, tv)
|
||||
}
|
||||
|
||||
func (h *MetricHandler) AddInt(key []byte, value []byte) {
|
||||
fk := unescape(key)
|
||||
fv, err := parseIntBytes(bytes.TrimSuffix(value, []byte("i")), 10, 64)
|
||||
if err != nil {
|
||||
log.Errorf("E! Received unparseable int value: %q", value)
|
||||
return
|
||||
}
|
||||
h.builder.AddField(fk, fv)
|
||||
}
|
||||
|
||||
func (h *MetricHandler) AddFloat(key []byte, value []byte) {
|
||||
fk := unescape(key)
|
||||
fv, err := parseFloatBytes(value, 64)
|
||||
if err != nil {
|
||||
log.Errorf("E! Received unparseable float value: %q", value)
|
||||
return
|
||||
}
|
||||
h.builder.AddField(fk, fv)
|
||||
}
|
||||
|
||||
func (h *MetricHandler) AddString(key []byte, value []byte) {
|
||||
fk := unescape(key)
|
||||
fv := stringFieldUnescape(value)
|
||||
h.builder.AddField(fk, fv)
|
||||
}
|
||||
|
||||
func (h *MetricHandler) AddBool(key []byte, value []byte) {
|
||||
fk := unescape(key)
|
||||
fv, err := parseBoolBytes(value)
|
||||
if err != nil {
|
||||
log.Errorf("E! Received unparseable boolean value: %q", value)
|
||||
return
|
||||
}
|
||||
h.builder.AddField(fk, fv)
|
||||
}
|
||||
|
||||
func (h *MetricHandler) SetTimestamp(tm []byte) {
|
||||
v, err := parseIntBytes(tm, 10, 64)
|
||||
if err != nil {
|
||||
log.Errorf("E! Received unparseable timestamp: %q", tm)
|
||||
return
|
||||
}
|
||||
ns := v * int64(h.precision)
|
||||
h.builder.SetTime(time.Unix(0, ns))
|
||||
}
|
||||
|
||||
func (h *MetricHandler) Reset() {
|
||||
h.builder.Reset()
|
||||
}
|
||||
21171
plugins/parsers/influx/machine.go
Normal file
21171
plugins/parsers/influx/machine.go
Normal file
File diff suppressed because it is too large
Load Diff
297
plugins/parsers/influx/machine.go.rl
Normal file
297
plugins/parsers/influx/machine.go.rl
Normal file
@@ -0,0 +1,297 @@
|
||||
package influx
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNameParse = errors.New("expected measurement name")
|
||||
ErrFieldParse = errors.New("expected field")
|
||||
ErrTagParse = errors.New("expected tag")
|
||||
ErrTimestampParse = errors.New("expected timestamp")
|
||||
ErrParse = errors.New("parse error")
|
||||
)
|
||||
|
||||
%%{
|
||||
machine LineProtocol;
|
||||
|
||||
action begin {
|
||||
m.pb = m.p
|
||||
}
|
||||
|
||||
action yield {
|
||||
yield = true
|
||||
fnext align;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action name_error {
|
||||
m.err = ErrNameParse
|
||||
fhold;
|
||||
fnext discard_line;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action field_error {
|
||||
m.err = ErrFieldParse
|
||||
fhold;
|
||||
fnext discard_line;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action tagset_error {
|
||||
m.err = ErrTagParse
|
||||
fhold;
|
||||
fnext discard_line;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action timestamp_error {
|
||||
m.err = ErrTimestampParse
|
||||
fhold;
|
||||
fnext discard_line;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action parse_error {
|
||||
m.err = ErrParse
|
||||
fhold;
|
||||
fnext discard_line;
|
||||
fbreak;
|
||||
}
|
||||
|
||||
action hold_recover {
|
||||
fhold;
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action discard {
|
||||
fgoto align;
|
||||
}
|
||||
|
||||
action name {
|
||||
m.handler.SetMeasurement(m.text())
|
||||
}
|
||||
|
||||
action tagkey {
|
||||
key = m.text()
|
||||
}
|
||||
|
||||
action tagvalue {
|
||||
m.handler.AddTag(key, m.text())
|
||||
}
|
||||
|
||||
action fieldkey {
|
||||
key = m.text()
|
||||
}
|
||||
|
||||
action integer {
|
||||
m.handler.AddInt(key, m.text())
|
||||
}
|
||||
|
||||
action float {
|
||||
m.handler.AddFloat(key, m.text())
|
||||
}
|
||||
|
||||
action bool {
|
||||
m.handler.AddBool(key, m.text())
|
||||
}
|
||||
|
||||
action string {
|
||||
m.handler.AddString(key, m.text())
|
||||
}
|
||||
|
||||
action timestamp {
|
||||
m.handler.SetTimestamp(m.text())
|
||||
}
|
||||
|
||||
ws =
|
||||
[\t\v\f ];
|
||||
|
||||
non_zero_digit =
|
||||
[1-9];
|
||||
|
||||
integer =
|
||||
'-'? ( digit | ( non_zero_digit digit* ) );
|
||||
|
||||
number =
|
||||
( integer ( '.' digit* )? ) | ( '.' digit* );
|
||||
|
||||
scientific =
|
||||
number 'e'i ["\-+"]? digit+;
|
||||
|
||||
timestamp =
|
||||
('-'? digit{1,19}) >begin %timestamp;
|
||||
|
||||
fieldkeychar =
|
||||
[^\t\n\f\r ,=\\] | ( '\\' [^\t\n\f\r] );
|
||||
|
||||
fieldkey =
|
||||
fieldkeychar+ >begin %fieldkey;
|
||||
|
||||
fieldfloat =
|
||||
(scientific | number) >begin %float;
|
||||
|
||||
fieldinteger =
|
||||
(integer 'i') >begin %integer;
|
||||
|
||||
false =
|
||||
"false" | "FALSE" | "False" | "F" | "f";
|
||||
|
||||
true =
|
||||
"true" | "TRUE" | "True" | "T" | "t";
|
||||
|
||||
fieldbool =
|
||||
(true | false) >begin %bool;
|
||||
|
||||
fieldstringchar =
|
||||
[^\\"] | '\\' [\\"];
|
||||
|
||||
fieldstring =
|
||||
fieldstringchar* >begin %string;
|
||||
|
||||
fieldstringquoted =
|
||||
'"' fieldstring '"';
|
||||
|
||||
fieldvalue = fieldinteger | fieldfloat | fieldstringquoted | fieldbool;
|
||||
|
||||
field =
|
||||
fieldkey '=' fieldvalue;
|
||||
|
||||
fieldset =
|
||||
field ( ',' field )*;
|
||||
|
||||
tagchar =
|
||||
[^\t\n\f\r ,=\\] | ( '\\' [^\t\n\f\r] );
|
||||
|
||||
tagkey =
|
||||
tagchar+ >begin %tagkey;
|
||||
|
||||
tagvalue =
|
||||
tagchar+ >begin %tagvalue;
|
||||
|
||||
tagset =
|
||||
(',' (tagkey '=' tagvalue) $err(tagset_error))*;
|
||||
|
||||
measurement_chars =
|
||||
[^\t\n\f\r ,\\] | ( '\\' [^\t\n\f\r] );
|
||||
|
||||
measurement_start =
|
||||
measurement_chars - '#';
|
||||
|
||||
measurement =
|
||||
(measurement_start measurement_chars*) >begin %name;
|
||||
|
||||
newline =
|
||||
[\r\n];
|
||||
|
||||
comment =
|
||||
'#' (any -- newline)* newline;
|
||||
|
||||
eol =
|
||||
ws* newline? >yield %eof(yield);
|
||||
|
||||
line =
|
||||
measurement
|
||||
tagset
|
||||
(ws+ fieldset) $err(field_error)
|
||||
(ws+ timestamp)? $err(timestamp_error)
|
||||
eol;
|
||||
|
||||
# The main machine parses a single line of line protocol.
|
||||
main := line $err(parse_error);
|
||||
|
||||
# The discard_line machine discards the current line. Useful for recovering
|
||||
# on the next line when an error occurs.
|
||||
discard_line :=
|
||||
(any - newline)* newline @discard;
|
||||
|
||||
# The align machine scans forward to the start of the next line. This machine
|
||||
# is used to skip over whitespace and comments, keeping this logic out of the
|
||||
# main machine.
|
||||
align :=
|
||||
(space* comment)* space* measurement_start @hold_recover %eof(yield);
|
||||
}%%
|
||||
|
||||
%% write data;
|
||||
|
||||
type machine struct {
|
||||
data []byte
|
||||
cs int
|
||||
p, pe, eof int
|
||||
pb int
|
||||
handler Handler
|
||||
err error
|
||||
}
|
||||
|
||||
func NewMachine(handler Handler) *machine {
|
||||
m := &machine{
|
||||
handler: handler,
|
||||
}
|
||||
|
||||
%% access m.;
|
||||
%% variable p m.p;
|
||||
%% variable pe m.pe;
|
||||
%% variable eof m.eof;
|
||||
%% variable data m.data;
|
||||
%% write init;
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *machine) SetData(data []byte) {
|
||||
m.data = data
|
||||
m.p = 0
|
||||
m.pb = 0
|
||||
m.pe = len(data)
|
||||
m.eof = len(data)
|
||||
m.err = nil
|
||||
|
||||
%% write init;
|
||||
m.cs = LineProtocol_en_align
|
||||
}
|
||||
|
||||
// ParseLine parses a line of input and returns true if more data can be
|
||||
// parsed.
|
||||
func (m *machine) ParseLine() bool {
|
||||
if m.data == nil || m.p >= m.pe {
|
||||
m.err = nil
|
||||
return false
|
||||
}
|
||||
|
||||
m.err = nil
|
||||
var key []byte
|
||||
var yield bool
|
||||
|
||||
%% write exec;
|
||||
|
||||
// Even if there was an error, return true. On the next call to this
|
||||
// function we will attempt to scan to the next line of input and recover.
|
||||
if m.err != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
// Don't check the error state in the case that we just yielded, because
|
||||
// the yield indicates we just completed parsing a line.
|
||||
if !yield && m.cs == LineProtocol_error {
|
||||
m.err = ErrParse
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Err returns the error that occurred on the last call to ParseLine. If the
|
||||
// result is nil, then the line was parsed successfully.
|
||||
func (m *machine) Err() error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
// Position returns the current position into the input.
|
||||
func (m *machine) Position() int {
|
||||
return m.p
|
||||
}
|
||||
|
||||
func (m *machine) text() []byte {
|
||||
return m.data[m.pb:m.p]
|
||||
}
|
||||
1312
plugins/parsers/influx/machine_test.go
Normal file
1312
plugins/parsers/influx/machine_test.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,112 @@
|
||||
package influx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
)
|
||||
|
||||
// InfluxParser is an object for Parsing incoming metrics.
|
||||
type InfluxParser struct {
|
||||
// DefaultTags will be added to every parsed metric
|
||||
DefaultTags map[string]string
|
||||
const (
|
||||
maxErrorBufferSize = 1024
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoMetric = errors.New("no metric in line")
|
||||
)
|
||||
|
||||
type Handler interface {
|
||||
SetMeasurement(name []byte)
|
||||
AddTag(key []byte, value []byte)
|
||||
AddInt(key []byte, value []byte)
|
||||
AddFloat(key []byte, value []byte)
|
||||
AddString(key []byte, value []byte)
|
||||
AddBool(key []byte, value []byte)
|
||||
SetTimestamp(tm []byte)
|
||||
Reset()
|
||||
}
|
||||
|
||||
func (p *InfluxParser) ParseWithDefaultTimePrecision(buf []byte, t time.Time, precision string) ([]telegraf.Metric, error) {
|
||||
if !bytes.HasSuffix(buf, []byte("\n")) {
|
||||
buf = append(buf, '\n')
|
||||
type ParseError struct {
|
||||
Offset int
|
||||
msg string
|
||||
buf string
|
||||
}
|
||||
|
||||
func (e *ParseError) Error() string {
|
||||
buffer := e.buf
|
||||
if len(buffer) > maxErrorBufferSize {
|
||||
buffer = buffer[:maxErrorBufferSize] + "..."
|
||||
}
|
||||
// parse even if the buffer begins with a newline
|
||||
buf = bytes.TrimPrefix(buf, []byte("\n"))
|
||||
metrics, err := metric.ParseWithDefaultTimePrecision(buf, t, precision)
|
||||
if len(p.DefaultTags) > 0 {
|
||||
for _, m := range metrics {
|
||||
for k, v := range p.DefaultTags {
|
||||
// only set the default tag if it doesn't already exist:
|
||||
if !m.HasTag(k) {
|
||||
m.AddTag(k, v)
|
||||
}
|
||||
return fmt.Sprintf("metric parse error: %s at offset %d: %q", e.msg, e.Offset, buffer)
|
||||
}
|
||||
|
||||
type Parser struct {
|
||||
DefaultTags map[string]string
|
||||
|
||||
*machine
|
||||
handler *MetricHandler
|
||||
}
|
||||
|
||||
func NewParser(handler *MetricHandler) *Parser {
|
||||
return &Parser{
|
||||
machine: NewMachine(handler),
|
||||
handler: handler,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
|
||||
metrics := make([]telegraf.Metric, 0)
|
||||
p.machine.SetData(input)
|
||||
|
||||
for p.machine.ParseLine() {
|
||||
err := p.machine.Err()
|
||||
if err != nil {
|
||||
return nil, &ParseError{
|
||||
Offset: p.machine.Position(),
|
||||
msg: err.Error(),
|
||||
buf: string(input),
|
||||
}
|
||||
}
|
||||
|
||||
metric, err := p.handler.Metric()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.handler.Reset()
|
||||
metrics = append(metrics, metric)
|
||||
}
|
||||
return metrics, err
|
||||
|
||||
p.applyDefaultTags(metrics)
|
||||
return metrics, nil
|
||||
}
|
||||
|
||||
// Parse returns a slice of Metrics from a text representation of a
|
||||
// metric (in line-protocol format)
|
||||
// with each metric separated by newlines. If any metrics fail to parse,
|
||||
// a non-nil error will be returned in addition to the metrics that parsed
|
||||
// successfully.
|
||||
func (p *InfluxParser) Parse(buf []byte) ([]telegraf.Metric, error) {
|
||||
return p.ParseWithDefaultTimePrecision(buf, time.Now(), "")
|
||||
}
|
||||
|
||||
func (p *InfluxParser) ParseLine(line string) (telegraf.Metric, error) {
|
||||
func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
||||
metrics, err := p.Parse([]byte(line + "\n"))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(metrics) < 1 {
|
||||
return nil, fmt.Errorf(
|
||||
"Can not parse the line: %s, for data format: influx ", line)
|
||||
return nil, ErrNoMetric
|
||||
}
|
||||
|
||||
return metrics[0], nil
|
||||
}
|
||||
|
||||
func (p *InfluxParser) SetDefaultTags(tags map[string]string) {
|
||||
func (p *Parser) SetDefaultTags(tags map[string]string) {
|
||||
p.DefaultTags = tags
|
||||
}
|
||||
|
||||
func (p *Parser) applyDefaultTags(metrics []telegraf.Metric) {
|
||||
if len(p.DefaultTags) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, m := range metrics {
|
||||
for k, v := range p.DefaultTags {
|
||||
if !m.HasTag(k) {
|
||||
m.AddTag(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,294 +1,488 @@
|
||||
package influx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
ms []telegraf.Metric
|
||||
writer = ioutil.Discard
|
||||
metrics500 []byte
|
||||
exptime = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).UnixNano()
|
||||
)
|
||||
|
||||
const (
|
||||
validInflux = "cpu_load_short,cpu=cpu0 value=10 1257894000000000000\n"
|
||||
negativeFloat = "cpu_load_short,cpu=cpu0 value=-13.4 1257894000000000000\n"
|
||||
validInfluxNewline = "\ncpu_load_short,cpu=cpu0 value=10 1257894000000000000\n"
|
||||
validInfluxNoNewline = "cpu_load_short,cpu=cpu0 value=10 1257894000000000000"
|
||||
invalidInflux = "I don't think this is line protocol\n"
|
||||
invalidInflux2 = "{\"a\": 5, \"b\": {\"c\": 6}}\n"
|
||||
invalidInflux3 = `name text="unescaped "quote" ",value=1 1498077493081000000`
|
||||
invalidInflux4 = `name text="unbalanced "quote" 1498077493081000000`
|
||||
)
|
||||
|
||||
const influxMulti = `
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
`
|
||||
|
||||
const influxMultiSomeInvalid = `
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,cpu=cpu3, host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
cpu,cpu=cpu4 , usage_idle=99,usage_busy=1
|
||||
cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||
`
|
||||
|
||||
func TestParseValidInflux(t *testing.T) {
|
||||
parser := InfluxParser{}
|
||||
|
||||
metrics, err := parser.Parse([]byte(validInflux))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, metrics, 1)
|
||||
assert.Equal(t, "cpu_load_short", metrics[0].Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(10),
|
||||
}, metrics[0].Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, exptime, metrics[0].Time().UnixNano())
|
||||
|
||||
metrics, err = parser.Parse([]byte(validInfluxNewline))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, metrics, 1)
|
||||
assert.Equal(t, "cpu_load_short", metrics[0].Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(10),
|
||||
}, metrics[0].Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, exptime, metrics[0].Time().UnixNano())
|
||||
|
||||
metrics, err = parser.Parse([]byte(validInfluxNoNewline))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, metrics, 1)
|
||||
assert.Equal(t, "cpu_load_short", metrics[0].Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(10),
|
||||
}, metrics[0].Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, exptime, metrics[0].Time().UnixNano())
|
||||
|
||||
metrics, err = parser.Parse([]byte(negativeFloat))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, metrics, 1)
|
||||
assert.Equal(t, "cpu_load_short", metrics[0].Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(-13.4),
|
||||
}, metrics[0].Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, exptime, metrics[0].Time().UnixNano())
|
||||
}
|
||||
|
||||
func TestParseLineValidInflux(t *testing.T) {
|
||||
parser := InfluxParser{}
|
||||
|
||||
metric, err := parser.ParseLine(validInflux)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "cpu_load_short", metric.Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(10),
|
||||
}, metric.Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metric.Tags())
|
||||
assert.Equal(t, exptime, metric.Time().UnixNano())
|
||||
|
||||
metric, err = parser.ParseLine(validInfluxNewline)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "cpu_load_short", metric.Name())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"value": float64(10),
|
||||
}, metric.Fields())
|
||||
assert.Equal(t, map[string]string{
|
||||
"cpu": "cpu0",
|
||||
}, metric.Tags())
|
||||
assert.Equal(t, exptime, metric.Time().UnixNano())
|
||||
}
|
||||
|
||||
func TestParseMultipleValid(t *testing.T) {
|
||||
parser := InfluxParser{}
|
||||
|
||||
metrics, err := parser.Parse([]byte(influxMulti))
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, metrics, 7)
|
||||
|
||||
for _, metric := range metrics {
|
||||
assert.Equal(t, "cpu", metric.Name())
|
||||
assert.Equal(t, map[string]string{
|
||||
"datacenter": "us-east",
|
||||
"host": "foo",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"usage_idle": float64(99),
|
||||
"usage_busy": float64(1),
|
||||
}, metrics[0].Fields())
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSomeValid(t *testing.T) {
|
||||
parser := InfluxParser{}
|
||||
|
||||
metrics, err := parser.Parse([]byte(influxMultiSomeInvalid))
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, metrics, 4)
|
||||
|
||||
for _, metric := range metrics {
|
||||
assert.Equal(t, "cpu", metric.Name())
|
||||
assert.Equal(t, map[string]string{
|
||||
"datacenter": "us-east",
|
||||
"host": "foo",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"usage_idle": float64(99),
|
||||
"usage_busy": float64(1),
|
||||
}, metrics[0].Fields())
|
||||
}
|
||||
}
|
||||
|
||||
// Test that default tags are applied.
|
||||
func TestParseDefaultTags(t *testing.T) {
|
||||
parser := InfluxParser{
|
||||
DefaultTags: map[string]string{
|
||||
"tag": "default",
|
||||
},
|
||||
}
|
||||
|
||||
metrics, err := parser.Parse([]byte(influxMultiSomeInvalid))
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, metrics, 4)
|
||||
|
||||
for _, metric := range metrics {
|
||||
assert.Equal(t, "cpu", metric.Name())
|
||||
assert.Equal(t, map[string]string{
|
||||
"datacenter": "us-east",
|
||||
"host": "foo",
|
||||
"tag": "default",
|
||||
}, metric.Tags())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"usage_idle": float64(99),
|
||||
"usage_busy": float64(1),
|
||||
}, metric.Fields())
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that metric tags will override default tags
|
||||
func TestParseDefaultTagsOverride(t *testing.T) {
|
||||
parser := InfluxParser{
|
||||
DefaultTags: map[string]string{
|
||||
"host": "default",
|
||||
},
|
||||
}
|
||||
|
||||
metrics, err := parser.Parse([]byte(influxMultiSomeInvalid))
|
||||
assert.Error(t, err)
|
||||
assert.Len(t, metrics, 4)
|
||||
|
||||
for _, metric := range metrics {
|
||||
assert.Equal(t, "cpu", metric.Name())
|
||||
assert.Equal(t, map[string]string{
|
||||
"datacenter": "us-east",
|
||||
"host": "foo",
|
||||
}, metrics[0].Tags())
|
||||
assert.Equal(t, map[string]interface{}{
|
||||
"usage_idle": float64(99),
|
||||
"usage_busy": float64(1),
|
||||
}, metrics[0].Fields())
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseInvalidInflux(t *testing.T) {
|
||||
parser := InfluxParser{}
|
||||
|
||||
_, err := parser.Parse([]byte(invalidInflux))
|
||||
assert.Error(t, err)
|
||||
_, err = parser.Parse([]byte(invalidInflux2))
|
||||
assert.Error(t, err)
|
||||
_, err = parser.Parse([]byte(invalidInflux3))
|
||||
assert.Error(t, err)
|
||||
fmt.Printf("%+v\n", err) // output for debug
|
||||
_, err = parser.Parse([]byte(invalidInflux4))
|
||||
assert.Error(t, err)
|
||||
|
||||
_, err = parser.ParseLine(invalidInflux)
|
||||
assert.Error(t, err)
|
||||
_, err = parser.ParseLine(invalidInflux2)
|
||||
assert.Error(t, err)
|
||||
_, err = parser.ParseLine(invalidInflux3)
|
||||
assert.Error(t, err)
|
||||
_, err = parser.ParseLine(invalidInflux4)
|
||||
assert.Error(t, err)
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkSingle(b *testing.B) {
|
||||
parser := InfluxParser{}
|
||||
b.ResetTimer()
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, err := parser.Parse([]byte("cpu value=42\n"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParse(b *testing.B) {
|
||||
var err error
|
||||
parser := InfluxParser{}
|
||||
for n := 0; n < b.N; n++ {
|
||||
// parse:
|
||||
ms, err = parser.Parse(metrics500)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(ms) != 500 {
|
||||
panic("500 metrics not parsed!!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParseAddTagWrite(b *testing.B) {
|
||||
var err error
|
||||
parser := InfluxParser{}
|
||||
for n := 0; n < b.N; n++ {
|
||||
ms, err = parser.Parse(metrics500)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if len(ms) != 500 {
|
||||
panic("500 metrics not parsed!!")
|
||||
}
|
||||
for _, tmp := range ms {
|
||||
tmp.AddTag("host", "localhost")
|
||||
writer.Write(tmp.Serialize())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
metrics500, err = ioutil.ReadFile("500.metrics")
|
||||
func Metric(v telegraf.Metric, err error) telegraf.Metric {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
var DefaultTime = func() time.Time {
|
||||
return time.Unix(42, 0)
|
||||
}
|
||||
|
||||
var ptests = []struct {
|
||||
name string
|
||||
input []byte
|
||||
metrics []telegraf.Metric
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "minimal",
|
||||
input: []byte("cpu value=42 0"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(0, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "minimal with newline",
|
||||
input: []byte("cpu value=42 0\n"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(0, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "measurement escape space",
|
||||
input: []byte(`c\ pu value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"c pu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "measurement escape comma",
|
||||
input: []byte(`c\,pu value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"c,pu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "tags",
|
||||
input: []byte(`cpu,cpu=cpu0,host=localhost value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{
|
||||
"cpu": "cpu0",
|
||||
"host": "localhost",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "tags escape unescapable",
|
||||
input: []byte(`cpu,ho\st=localhost value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{
|
||||
`ho\st`: "localhost",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "tags escape equals",
|
||||
input: []byte(`cpu,ho\=st=localhost value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{
|
||||
"ho=st": "localhost",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "tags escape comma",
|
||||
input: []byte(`cpu,ho\,st=localhost value=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{
|
||||
"ho,st": "localhost",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field key escape not escapable",
|
||||
input: []byte(`cpu va\lue=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`va\lue`: 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field key escape equals",
|
||||
input: []byte(`cpu va\=lue=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`va=lue`: 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field key escape comma",
|
||||
input: []byte(`cpu va\,lue=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`va,lue`: 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field key escape space",
|
||||
input: []byte(`cpu va\ lue=42`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`va lue`: 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field int",
|
||||
input: []byte("cpu value=42i"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field boolean",
|
||||
input: []byte("cpu value=true"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": true,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field string",
|
||||
input: []byte(`cpu value="42"`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": "42",
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field string escape quote",
|
||||
input: []byte(`cpu value="how\"dy"`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`value`: `how"dy`,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "field string escape backslash",
|
||||
input: []byte(`cpu value="how\\dy"`),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
`value`: `how\dy`,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "default timestamp",
|
||||
input: []byte("cpu value=42"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "multiple lines",
|
||||
input: []byte("cpu value=42\ncpu value=42"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
Metric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(42, 0),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
name: "invalid measurement only",
|
||||
input: []byte("cpu"),
|
||||
metrics: nil,
|
||||
err: &ParseError{
|
||||
Offset: 3,
|
||||
msg: ErrFieldParse.Error(),
|
||||
buf: "cpu",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "procstat",
|
||||
input: []byte("procstat,exe=bash,process_name=bash voluntary_context_switches=42i,memory_rss=5103616i,rlimit_memory_data_hard=2147483647i,cpu_time_user=0.02,rlimit_file_locks_soft=2147483647i,pid=29417i,cpu_time_nice=0,rlimit_memory_locked_soft=65536i,read_count=259i,rlimit_memory_vms_hard=2147483647i,memory_swap=0i,rlimit_num_fds_soft=1024i,rlimit_nice_priority_hard=0i,cpu_time_soft_irq=0,cpu_time=0i,rlimit_memory_locked_hard=65536i,realtime_priority=0i,signals_pending=0i,nice_priority=20i,cpu_time_idle=0,memory_stack=139264i,memory_locked=0i,rlimit_memory_stack_soft=8388608i,cpu_time_iowait=0,cpu_time_guest=0,cpu_time_guest_nice=0,rlimit_memory_data_soft=2147483647i,read_bytes=0i,rlimit_cpu_time_soft=2147483647i,involuntary_context_switches=2i,write_bytes=106496i,cpu_time_system=0,cpu_time_irq=0,cpu_usage=0,memory_vms=21659648i,memory_data=1576960i,rlimit_memory_stack_hard=2147483647i,num_threads=1i,cpu_time_stolen=0,rlimit_memory_rss_soft=2147483647i,rlimit_realtime_priority_soft=0i,num_fds=4i,write_count=35i,rlimit_signals_pending_soft=78994i,cpu_time_steal=0,rlimit_num_fds_hard=4096i,rlimit_file_locks_hard=2147483647i,rlimit_cpu_time_hard=2147483647i,rlimit_signals_pending_hard=78994i,rlimit_nice_priority_soft=0i,rlimit_memory_rss_hard=2147483647i,rlimit_memory_vms_soft=2147483647i,rlimit_realtime_priority_hard=0i 1517620624000000000"),
|
||||
metrics: []telegraf.Metric{
|
||||
Metric(
|
||||
metric.New(
|
||||
"procstat",
|
||||
map[string]string{
|
||||
"exe": "bash",
|
||||
"process_name": "bash",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"cpu_time": 0,
|
||||
"cpu_time_guest": float64(0),
|
||||
"cpu_time_guest_nice": float64(0),
|
||||
"cpu_time_idle": float64(0),
|
||||
"cpu_time_iowait": float64(0),
|
||||
"cpu_time_irq": float64(0),
|
||||
"cpu_time_nice": float64(0),
|
||||
"cpu_time_soft_irq": float64(0),
|
||||
"cpu_time_steal": float64(0),
|
||||
"cpu_time_stolen": float64(0),
|
||||
"cpu_time_system": float64(0),
|
||||
"cpu_time_user": float64(0.02),
|
||||
"cpu_usage": float64(0),
|
||||
"involuntary_context_switches": 2,
|
||||
"memory_data": 1576960,
|
||||
"memory_locked": 0,
|
||||
"memory_rss": 5103616,
|
||||
"memory_stack": 139264,
|
||||
"memory_swap": 0,
|
||||
"memory_vms": 21659648,
|
||||
"nice_priority": 20,
|
||||
"num_fds": 4,
|
||||
"num_threads": 1,
|
||||
"pid": 29417,
|
||||
"read_bytes": 0,
|
||||
"read_count": 259,
|
||||
"realtime_priority": 0,
|
||||
"rlimit_cpu_time_hard": 2147483647,
|
||||
"rlimit_cpu_time_soft": 2147483647,
|
||||
"rlimit_file_locks_hard": 2147483647,
|
||||
"rlimit_file_locks_soft": 2147483647,
|
||||
"rlimit_memory_data_hard": 2147483647,
|
||||
"rlimit_memory_data_soft": 2147483647,
|
||||
"rlimit_memory_locked_hard": 65536,
|
||||
"rlimit_memory_locked_soft": 65536,
|
||||
"rlimit_memory_rss_hard": 2147483647,
|
||||
"rlimit_memory_rss_soft": 2147483647,
|
||||
"rlimit_memory_stack_hard": 2147483647,
|
||||
"rlimit_memory_stack_soft": 8388608,
|
||||
"rlimit_memory_vms_hard": 2147483647,
|
||||
"rlimit_memory_vms_soft": 2147483647,
|
||||
"rlimit_nice_priority_hard": 0,
|
||||
"rlimit_nice_priority_soft": 0,
|
||||
"rlimit_num_fds_hard": 4096,
|
||||
"rlimit_num_fds_soft": 1024,
|
||||
"rlimit_realtime_priority_hard": 0,
|
||||
"rlimit_realtime_priority_soft": 0,
|
||||
"rlimit_signals_pending_hard": 78994,
|
||||
"rlimit_signals_pending_soft": 78994,
|
||||
"signals_pending": 0,
|
||||
"voluntary_context_switches": 42,
|
||||
"write_bytes": 106496,
|
||||
"write_count": 35,
|
||||
},
|
||||
time.Unix(0, 1517620624000000000),
|
||||
),
|
||||
),
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
}
|
||||
|
||||
func TestParser(t *testing.T) {
|
||||
for _, tt := range ptests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
handler := NewMetricHandler()
|
||||
handler.SetTimeFunc(DefaultTime)
|
||||
parser := NewParser(handler)
|
||||
|
||||
metrics, err := parser.Parse(tt.input)
|
||||
require.Equal(t, tt.err, err)
|
||||
|
||||
require.Equal(t, len(tt.metrics), len(metrics))
|
||||
for i, expected := range tt.metrics {
|
||||
require.Equal(t, expected.Name(), metrics[i].Name())
|
||||
require.Equal(t, expected.Tags(), metrics[i].Tags())
|
||||
require.Equal(t, expected.Fields(), metrics[i].Fields())
|
||||
require.Equal(t, expected.Time(), metrics[i].Time())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkParser(b *testing.B) {
|
||||
for _, tt := range ptests {
|
||||
b.Run(tt.name, func(b *testing.B) {
|
||||
handler := NewMetricHandler()
|
||||
parser := NewParser(handler)
|
||||
for n := 0; n < b.N; n++ {
|
||||
metrics, err := parser.Parse(tt.input)
|
||||
_ = err
|
||||
_ = metrics
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user