SumoLogic-Labs / sumo-powershell-sdk

Apache License 2.0
12 stars 5 forks source link

Put Error: collectors.validation.fields.invalid #2

Closed ultrafastneal closed 7 years ago

ultrafastneal commented 7 years ago

Hello,

I am experiencing a problem using the SumoLogic.psm1 Powershell script from https://github.com/SumoLogic/sumo-powershell-sdk/blob/master/sumologic/. I am getting an error making the following Put call to update an existing source, via the line

Invoke-RestMethod -Uri $url -Headers $headers -Method $method -WebSession $session.WebSession -Body (ConvertTo-Json $content)

Error JSON: Invoke-RestMethod : { "status" : 400, "id" : "IEKHA-25HT0-BRGH8", "code" : "collectors.validation.fields.invalid", "message" : "Invalid timestamp parsing settings. Ensure no timestamp format is specified when timestamp parsing is disabled." }

This call was working reliably for the past 4 months, but as of today, the call is no longer working. Sumo confirmed that they have changed the API. Are there any plans to update the PowerShell modules in this repo?

Here are the parameters for the Invoke-RestMethod

Url https://api.us2.sumologic.com/api/v1/collectors/114862187/sources/200049130

Method: Put

session.webSession: Headers : {[accept, application/json], [content-type, application/json]} Cookies : System.Net.CookieContainer UseDefaultCredentials : False Credentials : System.Net.NetworkCredential Certificates : UserAgent : Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.15063.296 Proxy : MaximumRedirection : -1

headers accept application/json If-Match "SpecificAlphaNumberIdHere" content-type application/json

content { "source": { "id": 200049130, "name": "webservice", "category": "cgm/ci/webservice", "automaticDateParsing": true, "multilineProcessingEnabled": true, "useAutolineMatching": false, "manualPrefixRegexp": "^\\d{4}-\\d{2}-\\d{2}[ ]\\d{2}:\\d{2}:\\d{2}.*", "forceTimeZone": false, "defaultDateFormat": "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027 \u0027HH:mm:ss", "defaultDateFormats": [ "@{format=yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027 \u0027HH:mm:ss}" ], "filters": [], "cutoffTimestamp": 0, "encoding": "UTF-8", "messagePerRequest": false, "url": "https://endpoint1.collection.us2.sumologic.com/receiver/v1/http/**********************************TokenHere**********************************", "sourceType": "HTTP", "alive": true, "collectorId": 114862187 } }

latkin commented 7 years ago

Hey @ultrafastneal, thanks for filing the issue.

We rolled out an updated configuration mechanism for timestamp parsing settings recently. It is meant to be backward compatible, but this issue is surely related.

The new timestamp config settings take the form of a nested object array on the source. I think the issue is that this powershell module wasn't capturing the nested config to a sufficient serialization depth.

Proposed fix is here: https://github.com/SumoLogic/sumo-powershell-sdk/pull/3 Can you try making that change locally and re-testing?

latkin commented 7 years ago

Merged the fix, this should address the issue. Please re-open if there are still problems.