Skip to content

Commit 844dfd3

Browse files
authored
Merge pull request #177913 from AbbyMSFT/patch-3
Removed python 2 sample
2 parents 611cb9b + 575c68b commit 844dfd3

File tree

2 files changed

+3
-86
lines changed

2 files changed

+3
-86
lines changed

articles/azure-monitor/logs/data-collector-api.md

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -381,90 +381,7 @@ namespace OIAPIExample
381381

382382
```
383383

384-
### Python 2 sample
385-
```python
386-
import json
387-
import requests
388-
import datetime
389-
import hashlib
390-
import hmac
391-
import base64
392-
393-
# Update the customer ID to your Log Analytics workspace ID
394-
customer_id = 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
395-
396-
# For the shared key, use either the primary or the secondary Connected Sources client authentication key
397-
shared_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
398-
399-
# The log type is the name of the event that is being submitted
400-
log_type = 'WebMonitorTest'
401-
402-
# An example JSON web monitor object
403-
json_data = [{
404-
"slot_ID": 12345,
405-
"ID": "5cdad72f-c848-4df0-8aaa-ffe033e75d57",
406-
"availability_Value": 100,
407-
"performance_Value": 6.954,
408-
"measurement_Name": "last_one_hour",
409-
"duration": 3600,
410-
"warning_Threshold": 0,
411-
"critical_Threshold": 0,
412-
"IsActive": "true"
413-
},
414-
{
415-
"slot_ID": 67890,
416-
"ID": "b6bee458-fb65-492e-996d-61c4d7fbb942",
417-
"availability_Value": 100,
418-
"performance_Value": 3.379,
419-
"measurement_Name": "last_one_hour",
420-
"duration": 3600,
421-
"warning_Threshold": 0,
422-
"critical_Threshold": 0,
423-
"IsActive": "false"
424-
}]
425-
body = json.dumps(json_data)
426-
427-
#####################
428-
######Functions######
429-
#####################
430-
431-
# Build the API signature
432-
def build_signature(customer_id, shared_key, date, content_length, method, content_type, resource):
433-
x_headers = 'x-ms-date:' + date
434-
string_to_hash = method + "\n" + str(content_length) + "\n" + content_type + "\n" + x_headers + "\n" + resource
435-
bytes_to_hash = bytes(string_to_hash).encode('utf-8')
436-
decoded_key = base64.b64decode(shared_key)
437-
encoded_hash = base64.b64encode(hmac.new(decoded_key, bytes_to_hash, digestmod=hashlib.sha256).digest())
438-
authorization = "SharedKey {}:{}".format(customer_id,encoded_hash)
439-
return authorization
440-
441-
# Build and send a request to the POST API
442-
def post_data(customer_id, shared_key, body, log_type):
443-
method = 'POST'
444-
content_type = 'application/json'
445-
resource = '/api/logs'
446-
rfc1123date = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
447-
content_length = len(body)
448-
signature = build_signature(customer_id, shared_key, rfc1123date, content_length, method, content_type, resource)
449-
uri = 'https://' + customer_id + '.ods.opinsights.azure.com' + resource + '?api-version=2016-04-01'
450-
451-
headers = {
452-
'content-type': content_type,
453-
'Authorization': signature,
454-
'Log-Type': log_type,
455-
'x-ms-date': rfc1123date
456-
}
457-
458-
response = requests.post(uri,data=body, headers=headers)
459-
if (response.status_code >= 200 and response.status_code <= 299):
460-
print 'Accepted'
461-
else:
462-
print "Response code: {}".format(response.status_code)
463-
464-
post_data(customer_id, shared_key, body, log_type)
465-
```
466-
467-
### Python 3 sample
384+
### Python sample
468385
```python
469386
import json
470387
import requests

articles/sentinel/create-custom-connector.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ While calling a RESTful endpoint directly requires more programming, it also pro
172172
For more information, see the [Log Analytics Data collector API](../azure-monitor/logs/data-collector-api.md), especially the following examples:
173173

174174
- [C#](../azure-monitor/logs/data-collector-api.md#c-sample)
175-
- [Python 2](../azure-monitor/logs/data-collector-api.md#python-2-sample)
175+
- [Python](../azure-monitor/logs/data-collector-api.md#python-sample)
176176

177177
## Connect with Azure Functions
178178

@@ -205,7 +205,7 @@ For more information on parsing at query time, see [Parsers](normalization-about
205205

206206
> [!NOTE]
207207
> Updating your parser also applies to data that you've already ingested into Azure Sentinel.
208-
>
208+
209209
## Next steps
210210

211211
Use the data ingested into Azure Sentinel to secure your environment with any of the following processes:

0 commit comments

Comments
 (0)